From 4034bac50f06410f428c4102c99ee0ac50f19e0a Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 7 Jul 2024 07:55:04 -0500 Subject: [PATCH 1/2] fix: `VERBOSE` environment variable accepting any value --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 5bf8118..61289ec 100644 --- a/src/index.js +++ b/src/index.js @@ -4,10 +4,11 @@ // WEB for web push. import log from 'npmlog'; -/* istanbul ignore if */ -if (process.env.VERBOSE || process.env.VERBOSE_PARSE_SERVER_PUSH_ADAPTER) { +/* c8 ignore start */ +if (process.env.VERBOSE === '1' || process.env.VERBOSE_PARSE_SERVER_PUSH_ADAPTER === '1') { log.level = 'verbose'; } +/* c8 ignore stop */ import ParsePushAdapter from './ParsePushAdapter.js'; import GCM from './GCM.js'; From d8a948582459a9f161aad1d45efd0a07a410c6fe Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:40:06 +0200 Subject: [PATCH 2/2] add bool parser --- src/index.js | 3 ++- src/utils.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/utils.js diff --git a/src/index.js b/src/index.js index 61289ec..74abea0 100644 --- a/src/index.js +++ b/src/index.js @@ -3,9 +3,10 @@ // PushAdapter, it uses GCM for android push, APNS for ios push. // WEB for web push. import log from 'npmlog'; +import { booleanParser } from './utils.js'; /* c8 ignore start */ -if (process.env.VERBOSE === '1' || process.env.VERBOSE_PARSE_SERVER_PUSH_ADAPTER === '1') { +if (booleanParser(process.env.VERBOSE || process.env.VERBOSE_PARSE_SERVER_PUSH_ADAPTER)) { log.level = 'verbose'; } /* c8 ignore stop */ diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..01fc659 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,10 @@ +function booleanParser(opt) { + if (opt == true || opt == 'true' || opt == '1') { + return true; + } + return false; +} + +export { + booleanParser, +}