Keep backup of .config.json

This commit is contained in:
Nick O'Leary
2018-03-20 00:04:36 +00:00
parent b307492487
commit 2845475e3f
3 changed files with 15 additions and 13 deletions

View File

@@ -78,7 +78,16 @@ module.exports = {
* This forces a fsync before completing to ensure
* the write hits disk.
*/
writeFile: function(path,content) {
writeFile: function(path,content,backupPath) {
if (backupPath) {
try {
console.log(path);
console.log(backupPath);
fs.renameSync(path,backupPath);
} catch(err) {
console.log(err);
}
}
return when.promise(function(resolve,reject) {
var stream = fs.createWriteStream(path);
stream.on('open',function(fd) {