2
0
mirror of https://github.com/frappe/books.git synced 2024-11-15 01:44:04 +00:00
books/server/utils.js

27 lines
658 B
JavaScript
Raw Normal View History

2018-03-30 16:57:25 +00:00
const fs = require('fs');
const path = require('path');
const getDirName = path.dirname;
const os = require('os');
2018-03-30 16:57:25 +00:00
module.exports = {
writeFile(fullpath, contents) {
return new Promise((resolve, reject) => {
fs.mkdir(getDirName(fullpath), {recursive:true}, (err) => {
2018-03-30 16:57:25 +00:00
if (err) reject(err);
fs.writeFile(fullpath, contents, (err) => {
if (err) reject(err);
resolve();
});
});
});
},
2018-07-14 16:31:14 +00:00
readFile(filepath) {
return fs.readFileSync(filepath, 'utf-8');
2018-07-14 16:31:14 +00:00
},
getTmpDir() {
return os.tmpdir();
2018-03-30 16:57:25 +00:00
}
2019-12-06 18:32:55 +00:00
}