mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
writeFile helper
This commit is contained in:
parent
89736618e6
commit
eb82b8d435
17
server/utils.js
Normal file
17
server/utils.js
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user