mirror of
https://github.com/frappe/books.git
synced 2024-12-26 12:28:12 +00:00
28 lines
672 B
JavaScript
28 lines
672 B
JavaScript
const mkdirp = require('mkdirp');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const getDirName = path.dirname;
|
|
const os = require('os');
|
|
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
},
|
|
|
|
readFile(filepath) {
|
|
return fs.readFileSync(filepath, 'utf-8');
|
|
},
|
|
|
|
getTmpDir() {
|
|
return os.tmpdir();
|
|
}
|
|
}
|