diff --git a/server/utils.js b/server/utils.js new file mode 100644 index 00000000..02a01901 --- /dev/null +++ b/server/utils.js @@ -0,0 +1,17 @@ +const mkdirp = require('mkdirp'); +const fs = require('fs'); +const getDirName = require('path').dirname; + +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(); + }); + }); + }); + } +} \ No newline at end of file