You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
910 B

var fs = require('fs');
var chalk = require('chalk');
/**
* File IO, error reporting.
*/
module.exports = {
/**
*
*/
read: function(file, aaa, bbb) {
return new Promise(function(resolve) {
fs.readFile(file, 'utf8', function(err, str) {
console.log('Read ' + file);
module.exports.error(err);
resolve(str || '');
});
});
},
/**
*
*/
write: function(file, str) {
return new Promise(function(resolve) {
if (str) {
fs.writeFile(file, str, module.exports.error, resolve);
console.log('Write ' + file);
}
else {
resolve();
}
});
},
/**
*
*/
error: function(e) {
if (e !== null) {
console.log(chalk.yellow(e));
}
}
};