2018-03-30 16:57:25 +00:00
|
|
|
const fs = require('fs');
|
2018-10-02 08:03:48 +00:00
|
|
|
const path = require('path');
|
|
|
|
const getDirName = path.dirname;
|
2018-04-14 19:14:02 +00:00
|
|
|
const os = require('os');
|
2018-03-30 16:57:25 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2021-11-09 10:42:39 +00:00
|
|
|
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();
|
2018-03-30 16:57:25 +00:00
|
|
|
});
|
2021-11-09 10:42:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2018-04-14 19:14:02 +00:00
|
|
|
|
2021-11-09 10:42:39 +00:00
|
|
|
readFile(filePath) {
|
|
|
|
return fs.readFileSync(filePath, 'utf-8');
|
|
|
|
},
|
2018-07-14 16:31:14 +00:00
|
|
|
|
2021-11-09 10:42:39 +00:00
|
|
|
getTmpDir() {
|
|
|
|
return os.tmpdir();
|
|
|
|
},
|
|
|
|
};
|