From bfde78268a6533df97ac43ef5db0f4d4b181d8db Mon Sep 17 00:00:00 2001 From: Zachary Boyd Date: Wed, 9 May 2018 18:19:06 -0700 Subject: [PATCH] Removes the data directory when the tor process exits --- src/TorProcess.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TorProcess.js b/src/TorProcess.js index 8a0093b..c8e5215 100644 --- a/src/TorProcess.js +++ b/src/TorProcess.js @@ -23,7 +23,7 @@ class TorProcess extends EventEmitter { exit(callback) { this.process.once('exit', (code) => { - del(this.tor_config.DataDirectory).then(() => callback && callback(null, code)).catch((error) => callback && callback(error, code)); + callback && callback(null, code); }); this.process.kill('SIGKILL'); } @@ -73,6 +73,10 @@ class TorProcess extends EventEmitter { shell: '/bin/bash' }); + tor.on('exit', () => { + del.sync(this.tor_config.DataDirectory); + }); + tor.stderr.on('data', (data) => { let error_message = Buffer.from(data).toString('utf8');