Skip to content

Commit

Permalink
make sure conf directory exists before writing the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-thomasberger authored and taylortom committed Sep 12, 2018
1 parent 300d314 commit 6aa5816
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions install.js
Expand Up @@ -548,12 +548,18 @@ function saveConfig(configItems, callback) {
_.each(configItems, function(value, key) {
config[key] = value;
});
fs.writeJson(path.join('conf', 'config.json'), config, { spaces: 2 }, function(error) {
if(error) {
handleError(`Failed to write configuration file to ${chalk.underline('conf/config.json')}.\n${error}`, 1, 'Install Failed.');

fs.ensureDir('conf', function(error) {
if (error) {
return handleError(`Failed to create configuration directory.\n${error}`, 1, 'Install Failed.');
}
return callback();
});
fs.writeJson(path.join('conf', 'config.json'), config, { spaces: 2 }, function(error) {
if(error) {
handleError(`Failed to write configuration file to ${chalk.underline('conf/config.json')}.\n${error}`, 1, 'Install Failed.');
}
return callback();
});
})
}

function handleError(error, exitCode, exitMessage) {
Expand Down

0 comments on commit 6aa5816

Please sign in to comment.