From 9c48cd3535dde23d435ccffb6c8865a0e3e83223 Mon Sep 17 00:00:00 2001 From: Chad Rickman Date: Thu, 29 Mar 2018 17:33:17 -0400 Subject: [PATCH 1/4] =?UTF-8?q?Changed=20the=20error=20variable=20on=20the?= =?UTF-8?q?=20child=20close=20event=20so=20it=20returns=20the=20error=20to?= =?UTF-8?q?=20the=20callback.=20I=20left=20the=20original=20logic=20of=20c?= =?UTF-8?q?hecking=20for=20a=20code,=20if=20error=20isn=E2=80=99t=20set.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/growl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/growl.js b/lib/growl.js index c38d3c1..b40b728 100644 --- a/lib/growl.js +++ b/lib/growl.js @@ -327,7 +327,7 @@ function growl(msg, opts, callback) { }); child.on('close', (code) => { - error = error || code === 0 ? null : code; + error = error ? error : code === 0 ? null : code; if (typeof fn === 'function') { fn(error, stdout, stderr); } From 8deca6b16ab0bf6ad16f89724308bb9060bf7d2f Mon Sep 17 00:00:00 2001 From: Chad Rickman Date: Tue, 3 Apr 2018 20:17:35 -0400 Subject: [PATCH 2/4] Removed unncessary ternary statement. --- lib/growl.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/growl.js b/lib/growl.js index b40b728..9cf1c57 100644 --- a/lib/growl.js +++ b/lib/growl.js @@ -327,14 +327,12 @@ function growl(msg, opts, callback) { }); child.on('close', (code) => { - error = error ? error : code === 0 ? null : code; if (typeof fn === 'function') { fn(error, stdout, stderr); } }); } - /** * Expose `growl`. */ From 1604d18cba34500d3fbe0395abdbcbec9cfba40f Mon Sep 17 00:00:00 2001 From: Chad Rickman Date: Tue, 3 Apr 2018 20:53:12 -0400 Subject: [PATCH 3/4] Fixed the unit test, since error is only returned if an error is passed to the callback. --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index 9bb09d9..3b1d229 100644 --- a/test.js +++ b/test.js @@ -17,7 +17,7 @@ growl('Show pdf filesystem icon', { image: 'article.pdf' }, function(){ }) growl('Show pdf filesystem icon', { title: 'Use show()', image: 'article.pdf' }) growl('here \' are \n some \\ characters that " need escaping', {}, function(error, stdout, stderr) { - if (error !== null) throw new Error('escaping failed:\n' + stdout + stderr); + if (error) throw new Error('escaping failed:\n' + stdout + stderr); }) growl('Allow custom notifiers', { exec: 'echo XXX %s' }, function(error, stdout, stderr) { console.log(stdout); From ca681ade6f07afbdaf33458aa835f1d39273780b Mon Sep 17 00:00:00 2001 From: Chad Rickman Date: Tue, 3 Apr 2018 21:06:05 -0400 Subject: [PATCH 4/4] Fixed lint error. --- lib/growl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/growl.js b/lib/growl.js index 9cf1c57..eb4efa8 100644 --- a/lib/growl.js +++ b/lib/growl.js @@ -326,7 +326,7 @@ function growl(msg, opts, callback) { stderr += data; }); - child.on('close', (code) => { + child.on('close', () => { if (typeof fn === 'function') { fn(error, stdout, stderr); }