@cypress/env-or-json-file

中文文档
2.0.0发布于 2017/10/31MITCommonJS近 30 天下载 2648

Loads JSON object from environment string or local file

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录7 节
  1. Install
  2. Use
  3. Debug
  4. Filename
  5. Tips
  6. Small print
  7. MIT License

@cypress/env-or-json-file

Loads JSON object from environment string or local file

NPM

Build status Build status semantic-release js-standard-style

Install

Requires Node version 6 or above.

npm install --save @cypress/env-or-json-file

Use

If you have configuration file locally foo.json with all your settings, load it directly

const {configFromEnvOrJsonFile} = require('@cypress/env-or-json-file')
const config = configFromEnvOrJsonFile('foo.json')
if (config) {
  // ok, loaded somehow
} else {
  console.error('Missing config...')
}

But when you move to CI, just grab the file's contents and put it as environment variable foo_json (environment variables often have restrictions on characters, so replace all /.- characters in the path with _)

cat foo.json | pbcopy

Paste the contents into CI variable foo_json and it should load the config on CI without checking in a sensitive file.

Debug

To see verbose log message from this module, run with DEBUG=env-or-json-file ... environment variable.

Filename

Given a filename with path, function filenameToShellVariable converts it to environment key name, normalizing slashes and dots.

const {filenameToShellVariable} = require('@cypress/env-or-json-file')
filenameToShellVariable('foo/bar/.me.json')
// foo_bar__me_json

Tips

Stop CircleCI default variable leak

Small print

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

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2017 Cypress.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

版本与发布记录

@cypress/env-or-json-file 共发布 5 个版本,首次发布于 2017/07/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2017/10/319 年前
1.2.02017/09/279 年前
1.1.02017/09/199 年前
1.0.12017/07/139 年前
1.0.02017/07/139 年前

关于 @cypress/env-or-json-file 的常见问题

@cypress/env-or-json-file 是什么?

Loads JSON object from environment string or local file注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @cypress/env-or-json-file?

在项目目录运行 npm install @cypress/env-or-json-file,或使用 pnpm add / yarn add / bun add。

@cypress/env-or-json-file 支持 TypeScript 吗?

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

@cypress/env-or-json-file 支持 ESM 还是 CommonJS?

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

@cypress/env-or-json-file 需要什么版本的 Node.js?

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

@cypress/env-or-json-file 可以商用吗?

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

@cypress/env-or-json-file 的下载量有多少?

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

@cypress/env-or-json-file 还在维护吗?

最新版本 2.0.0 发布于 2017/10/31(9 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/07/13。作者已将其标记为弃用,新项目建议寻找替代方案。