Task #27 - Archive shell script

This commit is contained in:
QiTao 2020-02-08 12:19:25 -06:00
parent d3cd8b4d38
commit ec0ebda861

View File

@ -41,7 +41,17 @@ class Export extends Controller {
await fs.mkdir(temp_dir) await fs.mkdir(temp_dir)
this._markdown_recurse(page0, temp_dir) this._markdown_recurse(page0, temp_dir)
return res.api({ temp_dir })
const exec = require('child_process').exec;
exec('zip -r ' + path.resolve(temp_dir, 'archive.zip') + ' ' + path.resolve(temp_dir), (error) => {
if (error) {
console.error(`exec error: ${error}`);
return res.error(500);
return;
}
return res.sendFile(`${path.resolve(temp_dir, 'archive.zip')}`)
})
} }
async _markdown_recurse(root, temp_dir) { //recursive function for creating directory and generating markdown pages async _markdown_recurse(root, temp_dir) { //recursive function for creating directory and generating markdown pages