summaryrefslogtreecommitdiff
path: root/modules/changes
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-05 23:49:56 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-05 23:49:56 +0100
commit7aedcb7447f1bfd10d0c12233594ffb1e0473fbd (patch)
tree98837185ddb7080364d294520e1afa9eaa096c3a /modules/changes
parentc57e57f5ba31db9b8d57f58ce98aab6eac9e48d7 (diff)
changes: Clean up /tmp files after diffing
Diffstat (limited to 'modules/changes')
-rw-r--r--modules/changes/changes.js11
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);