2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00
books/server/utils.js
2018-03-30 22:27:25 +05:30

17 lines
488 B
JavaScript

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();
});
});
});
}
}