@bahmutov/print-env

中文文档
2.1.2发布于 2020/06/13MITCommonJS近 30 天下载 2.9万

Prints all environment variables that start with given string

原始使用文档
文档目录9 节
  1. Installation and usage
  2. exit code
  3. npx
  4. Publishing new version
  5. About
  6. Author
  7. Collaborators
  8. License
  9. Support

@bahmutov/print-env renovate-app badge

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

NPM

Build status semantic-release js-standard-style

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 command 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

Publishing new version

New versions are automatically published to NPM from CI using semantic-release tool. In order for new version to be published, there should be commits since the last published version that have the subject with semantic convention.

fix: stop graphite breaking when too much pressure applied | patch release
feat: explain the feature | minor release

When making pull request, edit the title of the squashed commit - this is what semantic release will look at to decide if a new version should be published or not. If you forget, no big deal, just push an empty commit with desired release subject

git commit --allow-empty -m "feat: new exciting feature"
git push

About

Author

Gleb Bahmutov <[email protected]> © 2017

Collaborators

License

MIT - do anything with the code, but don't blame me if it does not work.

Support

If you find any problems with this module, email / tweet / open issue on Github

版本与发布记录

@bahmutov/print-env 共发布 12 个版本,首次发布于 2017/10/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.2latest2020/06/136 年前
2.1.12020/04/256 年前
2.1.02020/04/196 年前
2.0.22020/03/246 年前
2.0.12020/03/246 年前
2.0.02020/03/246 年前

关于 @bahmutov/print-env 的常见问题

@bahmutov/print-env 是什么?

Prints all environment variables that start with given string

如何安装 @bahmutov/print-env?

在项目目录运行 npm install @bahmutov/print-env,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 print-env,可以用 npx print-env 直接运行。

@bahmutov/print-env 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bahmutov__print-env 是否存在。

@bahmutov/print-env 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bahmutov/print-env 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=6。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bahmutov/print-env 可以商用吗?

@bahmutov/print-env 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bahmutov/print-env 的下载量有多少?

根据 npm 官方下载统计,@bahmutov/print-env 在 2026/10/08 – 2026/11/06 这 30 天内被下载 29,467 次,日均约 982 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bahmutov/print-env 还在维护吗?

最新版本 2.1.2 发布于 2020/06/13(6 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/10/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。