2
0
mirror of https://github.com/frappe/books.git synced 2025-01-28 01:28:28 +00:00
books/server/utils.js

28 lines
672 B
JavaScript
Raw Normal View History

2018-03-30 22:27:25 +05:30
const mkdirp = require('mkdirp');
const fs = require('fs');
const path = require('path');
const getDirName = path.dirname;
const os = require('os');
2018-03-30 22:27:25 +05:30
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();
});
});
});
},
2018-07-14 22:01:14 +05:30
readFile(filepath) {
return fs.readFileSync(filepath, 'utf-8');
2018-07-14 22:01:14 +05:30
},
getTmpDir() {
return os.tmpdir();
2018-03-30 22:27:25 +05:30
}
2019-12-07 00:02:55 +05:30
}