diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-05 23:49:56 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-05 23:49:56 +0100 |
commit | 7aedcb7447f1bfd10d0c12233594ffb1e0473fbd (patch) | |
tree | 98837185ddb7080364d294520e1afa9eaa096c3a | |
parent | c57e57f5ba31db9b8d57f58ce98aab6eac9e48d7 (diff) |
changes: Clean up /tmp files after diffing
-rw-r--r-- | modules/changes/changes.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js index 8a0b3d9..3c75671 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -436,12 +436,21 @@ module.exports=function(app,io,_moddir){ } counter++; if(counter<2)return; + var proc=child_process.spawn( "diff", [folder+"/old.html",folder+"/new.html"], {stdio:[process.stdin,fs.openSync(folder+"/diff.txt","w"),process.stderr]}); + proc.on("exit",function(code,signal){ - fs.createReadStream(folder+"/diff.txt").pipe(res); + var stream=fs.createReadStream(folder+"/diff.txt"); + stream.pipe(res); + stream.on("end",function(){ + fs.unlinkSync(folder+"/old.html"); + fs.unlinkSync(folder+"/new.html"); + fs.unlinkSync(folder+"/diff.txt"); + fs.rmdirSync(folder); + }); }); }; fs.writeFile(folder+"/old.html",tl[oldi][2],fscb); |