diff --git a/lib/index.js b/lib/index.js index 504c2ade9d22e67443540fc8f471ae868daafd76..bd8dacf91236eb37d0b0eb522673cf1a47c9b037 100644 --- a/lib/index.js +++ b/lib/index.js @@ -52,7 +52,7 @@ var Worker = (function () { }, { key: "terminate", value: function terminate() { - this.child.kill(); + this.child.kill("SIGHUP"); } }]); diff --git a/lib/worker.js b/lib/worker.js index b4d2b7ba54924f3d962b1086852e2b2833cf66c3..3c7576a4a584756762aa24e751ef535b9aa328ef 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -47,8 +47,7 @@ process.once("message", function (obj) { global.require = require; global.importScripts = function () { - var script = undefined, - scripts = undefined; + var scripts = undefined; for (var _len = arguments.length, files = Array(_len), _key = 0; _key < _len; _key++) { files[_key] = arguments[_key]; @@ -59,8 +58,7 @@ process.once("message", function (obj) { return fs.readFileSync(file, "utf8"); }).join("\n"); - script = vm.createScript(scripts); - script.runInThisContext(); + vm.createScript(scripts).runInThisContext(); } }; diff --git a/package.json b/package.json index 1a4234853819bf6f6120b1886847b43f92dab636..939f16df941f55b7d5ba348f6eb11718cc0b84ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiny-worker", - "version": "1.1.0", + "version": "1.1.1", "description": "Tiny WebWorker for Server", "main": "lib/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index 5914921395e18b74fc710e930c4c1d4b028950b2..85674f8c384f417a95fc60f3c115ee6118d597a9 100644 --- a/src/index.js +++ b/src/index.js @@ -38,7 +38,7 @@ class Worker { } terminate () { - this.child.kill(); + this.child.kill("SIGHUP"); } } diff --git a/src/worker.js b/src/worker.js index 11a8494123ac0edfb9b0ba340cff95a0937fcd55..b3bfb6777506dd0aa4fb0841cdb0e77a49d7cc28 100644 --- a/src/worker.js +++ b/src/worker.js @@ -45,15 +45,14 @@ process.once("message", function (obj) { global.require = require; global.importScripts = function (...files) { - let script, scripts; + let scripts; if (files.length > 0) { scripts = files.map(function (file) { return fs.readFileSync(file, "utf8"); }).join("\n"); - script = vm.createScript(scripts); - script.runInThisContext(); + vm.createScript(scripts).runInThisContext(); } };