2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/server/utils.js

22 lines
568 B
JavaScript
Raw Normal View History

2018-03-30 16:57:25 +00:00
const mkdirp = require('mkdirp');
const fs = require('fs');
const getDirName = require('path').dirname;
const os = require('os');
2018-03-30 16:57:25 +00:00
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();
});
});
});
},
getTmpDir() {
return os.tmpdir();
2018-03-30 16:57:25 +00:00
}
}