From 3ee55631f1324b491c87c9c99e145e66ba0fb7f9 Mon Sep 17 00:00:00 2001 From: Jason Mulligan <jason.mulligan@avoidwork.com> Date: Tue, 29 Sep 2015 18:39:08 -0400 Subject: [PATCH] Fleshing it out a little --- lib/index.js | 12 ++++++++---- lib/worker.js | 15 +++++++++++++++ src/index.js | 10 +++++++--- src/worker.js | 13 +++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 lib/worker.js create mode 100644 src/worker.js diff --git a/lib/index.js b/lib/index.js index 30dc184..511bf67 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,15 @@ -//const path = require("path"); - "use strict"; +var path = require("path"); +var worker = require(path.join(__dirname, "worker.js")); + function factory(arg) { - var fn = typeof arg === "function"; + var fn = typeof arg === "function", + obj = undefined; + + obj = worker(arg, fn); - return fn; + return obj; } module.exports = factory; diff --git a/lib/worker.js b/lib/worker.js new file mode 100644 index 0000000..35e0866 --- /dev/null +++ b/lib/worker.js @@ -0,0 +1,15 @@ +"use strict"; + +var spawn = require("child_process").spawn; + +function factory(arg) { + var ps = spawn("grep", [arg]); + + ps.on("close", function (code, signal) { + console.log("child process terminated due to receipt of signal " + signal); + }); + + return ps; +} + +module.exports = factory; diff --git a/src/index.js b/src/index.js index 7c9cf2a..b884591 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,13 @@ -//const path = require("path"); +const path = require("path"); +const worker = require(path.join(__dirname, "worker.js")); function factory (arg) { - let fn = typeof arg === "function"; + let fn = typeof arg === "function", + obj; - return fn; + obj = worker(arg, fn); + + return obj; } module.exports = factory; diff --git a/src/worker.js b/src/worker.js new file mode 100644 index 0000000..c123c88 --- /dev/null +++ b/src/worker.js @@ -0,0 +1,13 @@ +const spawn = require("child_process").spawn; + +function factory (arg) { + let ps = spawn("grep", [arg]); + + ps.on("close", function (code, signal) { + console.log("child process terminated due to receipt of signal " + signal); + }); + + return ps; +} + +module.exports = factory; -- GitLab