From 1e4953db76fd3f0db1e2ea15ed1274730d8167a6 Mon Sep 17 00:00:00 2001 From: indexzero Date: Tue, 30 Jun 2015 23:42:52 -0700 Subject: [PATCH] [fix] Do not break tests. --- lib/forever.js | 14 ++++++++------ test/core/stopbypid-peaceful-test.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/forever.js b/lib/forever.js index 5c9c72d0..0f8d952b 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -758,14 +758,16 @@ forever.findByUid = function (script, processes) { // Finds the process with the specified pid. // forever.findByPid = function (pid, processes) { - var procs = !processes - ? null - : processes.filter(function (p) { - return p.pid === pid; - }); + pid = typeof pid === 'string' + ? parseInt(pid, 10) + : pid; + + var procs = processes && processes.filter(function (p) { + return p.pid === pid; + }); if (procs && procs.length === 0) { procs = null; } - return procs; + return procs || null; }; // diff --git a/test/core/stopbypid-peaceful-test.js b/test/core/stopbypid-peaceful-test.js index f20ba756..7c0ef45f 100644 --- a/test/core/stopbypid-peaceful-test.js +++ b/test/core/stopbypid-peaceful-test.js @@ -75,4 +75,4 @@ vows.describe('forever/core/stopbypid-peaceful').addBatch({ } } } -}).export(module); \ No newline at end of file +}).export(module);