Little util function for simpler extracting Boolean
values from ENV
variables in Node.js, i.e. true
values (true
, TRUE
, 1
) vs. false
values (false
, FALSE
, 0
).
const DEFAULT_FOO = 1
const flag = require('node-env-flag')
const yep = flag(process.env.FOO, DEFAULT_FOO)
if (yep) {
console.log("Foo!")
}
-
(value)
flag(process.env.FOO);
-
(value, default)
flag(process.env.FOO, 1);
$ npm install node-env-flag
Local tests:
$ make test
Released under the MIT license.
Copyright (c) Jonas Grimfelt