SYNOPSIS
Bash programming does not read clearly inside a package.json
script field.
This program helps test environment variables and create conditional output.
EXAMPLE
package.json
scripts likely want some context about their environment. In
this example we want to add the --debug
flag to the browserify
program
before we run it, but only if the NODE_ENV
environment variable has not
been set.
"scripts":
USAGE
TESTING
If the variable exists, the second argument will be written to stdout
. If the test is false,
and a third variable is supplied it will be printed.
$test-env VARIABLE_NAME Yes
$test-env VARIABLE_NAME Yep Nope
If the variable does not exist, the second argument will be written to stdout
. If the test
is false, and a third variable is supplied it will be printed.
$test-env !USER "Yeah ok, sure"
$test-env !USER 1 2
COMPARING
The comparison operators are supported
==
(oreq
) Equal!=
(ornot
) Not Equalgt
Greater Thanlt
Less Thangte
Greater Than or Equal Tolte
Less Than or Equal To
$test-env SHLVL == 2 Yep NopeYep
$test-env SHLVL gte 1 OK "NOT OK"OK