Task #27 - Archive shell script
This commit is contained in:
parent
d3cd8b4d38
commit
ec0ebda861
@ -41,7 +41,17 @@ class Export extends Controller {
|
||||
|
||||
await fs.mkdir(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
|
||||
|
Loading…
Reference in New Issue
Block a user