2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 19:39:07 +00:00
books/server/utils.js
Faris Ansari 32cd6581d1 PDF generation
- /api/method/pdf
- frappe.getPDF
- download using blob url
2018-04-15 00:44:02 +05:30

22 lines
568 B
JavaScript

const mkdirp = require('mkdirp');
const fs = require('fs');
const getDirName = require('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();
});
});
});
},
getTmpDir() {
return os.tmpdir();
}
}