From f4540412077f2b6f87b99faf53c1140fe8b3a649 Mon Sep 17 00:00:00 2001 From: binarybaron Date: Mon, 17 Jan 2022 18:35:33 +0100 Subject: [PATCH] Use the promise version of `execFile` --- index.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 315c5aa..c6b4f9a 100644 --- a/index.js +++ b/index.js @@ -84,16 +84,9 @@ const psOutputRegex = /^[ \t]*(?\d+)[ \t]+(?\d+)[ \t]+(?\d+)[ \t const nonWindowsSingleCall = async (options = {}) => { const flags = options.all === false ? 'wwxo' : 'awwxo'; - // TODO: Use the promise version of `execFile` when https://github.com/nodejs/node/issues/28244 is fixed. - const [psPid, stdout] = await new Promise((resolve, reject) => { - const child = childProcess.execFile('ps', [flags, psFields], {maxBuffer: TEN_MEGABYTES}, (error, stdout) => { - if (error === null) { - resolve([child.pid, stdout]); - } else { - reject(error); - } - }); - }); + const promise = execFile('ps', [flags, psFields], {maxBuffer: TEN_MEGABYTES}); + const {stdout} = await promise; + const {pid: psPid} = promise.child; const lines = stdout.trim().split('\n'); lines.shift();