2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

writeFile helper

This commit is contained in:
Faris Ansari 2018-03-30 22:27:25 +05:30
parent 89736618e6
commit eb82b8d435

17
server/utils.js Normal file
View File

@ -0,0 +1,17 @@
const mkdirp = require('mkdirp');
const fs = require('fs');
const getDirName = require('path').dirname;
module.exports = {
writeFile(fullpath, contents) {
return new Promise((resolve, reject) => {
mkdirp(getDirName(fullpath), (err) => {
if (err) reject(err);
fs.writeFile(fullpath, contents, (err) => {
if (err) reject(err);
resolve();
});
});
});
}
}