From ea36173e8f472ef4b1dad3b397073c0f5b1efcf9 Mon Sep 17 00:00:00 2001 From: "JASSELETTE, Denis" Date: Tue, 18 Jul 2023 12:58:58 +0200 Subject: [PATCH] Resolve #49 --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 584168b..6d7ccef 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ module.exports = function (port, method = 'tcp') { // The regex here will match only the local port column of the output const lineWithLocalPortRegEx = new RegExp(`^ *${method.toUpperCase()} *[^ ]*:${port}`, 'gm') const linesWithLocalPort = lines.filter(line => line.match(lineWithLocalPortRegEx)) + if (!linesWithLocalPort.length) return Promise.reject(new Error('No process running on port')) const pids = linesWithLocalPort.reduce((acc, line) => { const match = line.match(/(\d*)\w*(\n|$)/gm)