From 2dbd8c8241e248bdbbd0d2bd9f187d8ffcd39882 Mon Sep 17 00:00:00 2001 From: Basia Madej Date: Tue, 25 Oct 2022 15:53:20 +0200 Subject: [PATCH] Allow PIDUSAGE_USE_PS to have string type of "true" (#141) --- index.js | 2 +- test/ps.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3115bbe..a572b4a 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,7 @@ function pidusage (pids, options, callback) { } options = Object.assign({ - usePs: process.env.PIDUSAGE_USE_PS, + usePs: /^true$/i.test(process.env.PIDUSAGE_USE_PS), maxage: process.env.PIDUSAGE_MAXAGE }, options) diff --git a/test/ps.js b/test/ps.js index 36bbba8..edbf477 100644 --- a/test/ps.js +++ b/test/ps.js @@ -158,11 +158,11 @@ test('should be able to set usePs from env var', async t => { let usePsFromStats mockery.registerMock('./lib/stats', (_, options) => { - usePsFromStats = !!options.usePs + usePsFromStats = options.usePs }) const beforeValue = process.env.PIDUSAGE_USE_PS - process.env.PIDUSAGE_USE_PS = '1' + process.env.PIDUSAGE_USE_PS = 'true' const pidusage = require('../') pidusage(1, () => {})