mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
27 lines
579 B
JavaScript
27 lines
579 B
JavaScript
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) => {
|
|
fs.mkdir(getDirName(fullpath), { recursive: true }, (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();
|
|
},
|
|
};
|