Skip to content

Commit

Permalink
fs.ensureFile to fix missing .tessel dir in Preferences.write
Browse files Browse the repository at this point in the history
Fix for issue #820
  • Loading branch information
jandrieu committed Aug 19, 2016
1 parent 1daa725 commit 67e38ca
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ Preferences.write = function(key, value) {
.then(contents => {
contents = contents || {};
contents[key] = value;
fs.writeFile(preferencesJson, JSON.stringify(contents), function(error) {
fs.ensureFile(preferencesJson, function(err){
if (error) {
log.error('Error writing preference', key, value);
reject(error);
} else {
resolve();
fs.writeFile(preferencesJson, JSON.stringify(contents), function(error) {
if (error) {
log.error('Error writing preference', key, value);
reject(error);
} else {
resolve();
}
});
}
});
})
})
.catch(error => {
reject(error);
Expand Down

0 comments on commit 67e38ca

Please sign in to comment.