← 全部工具

@bahmutov/print-env

热度 65 更新于 开发与构建

Prints all environment variables that start with given string

npmauto-collected

安装

npm
npm install -g @bahmutov/print-env

通过 npm 安装。

@bahmutov/print-env [![renovate-app badge][renovate-badge]][renovate-app]

Prints all environment variables that start with given string(s)

Installation and usage

Requires Node version 6 or above.

Usually on your CI, you can just install this CLI tool globally

npm install -g @bahmutov/print-env
$ print-env
Usage: print-env [options] <PREFIX>...

Finds and prints the names and values of all environment variables present that start with any of the PREFIXes

Options:
  -e, --exists  Print only variable names
  -h, --help    display help for command

Call the tool with 1 or more prefixes, for example to show all vars beginning with TRAVIS or NODE:

$ print-env TRAVIS NODE
NODE_ENV=development
TRAVIS_BRANCH=master
TRAVIS_SUDO=false
TRAVIS_NODE_VERSION=8
TRAVIS_PRE_CHEF_BOOTSTRAP_TIME=2017-08-29T02:16:18
...

Variables are sorted alphabetically.

You can also check if sensitive variables are present using the -e|--exists flag with the desired prefixes, in which case only the names of environment variables are printed:

$ print-env -e GH
Found environment variables that start with GH:
GH_API_KEY
GH_INSTALLATION_ID
...

exit code

If there are no variables starting with the given prefix, the tool with exit with code 1

$ print-env -e FOO
No environment variables found that start with FOO

$ echo $?
1

npx

You can run this tool without installing it permanently using npx command

$ npx @bahmutov/print-env --exists USER
npx: installed 1 in 0.737s
Found environment variables that start with USER:
USER

$ npx @bahmutov/print-env USER
npx: installed 1 in 1.975s
Found environment variables that start with USER:
USER=gleb