allow startup without settings file

This commit is contained in:
Matthias Bartelmeß 2012-04-20 17:03:26 +02:00
parent 6fc45d6252
commit 90bbf169b2
1 changed files with 9 additions and 3 deletions

View File

@ -106,9 +106,15 @@ if (settingsFilename.charAt(0) != '/') {
settingsFilename = path.normalize(path.join(root, settingsFilename));
}
//read the settings sync
var settingsStr = fs.readFileSync(settingsFilename).toString();
var settingsStr
try{
//read the settings sync
settingsStr = fs.readFileSync(settingsFilename).toString();
} catch(e){
console.warn('No settings file found. Using defaults.');
settingsStr = '{}';
}
//remove all comments
settingsStr = settingsStr.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/gm,"").replace(/#.*/g,"").replace(/\/\/.*/g,"");