is-npm:检查您的代码是否以npm或yarn脚本运行

  • R4_694723
    了解作者
  • 5.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-08 17:43
    上传日期
is-npm 检查您的代码是否以或脚本运行 安装 $ npm install is-npm 用法 const { isNpmOrYarn , isNpm , isYarn } = require ( 'is-npm' ) ; console . table ( { isNpmOrYarn , isNpm , isYarn } ) ; $ node foo.js # ┌─────────────┬────────┐ # │ (index) │ Values │ # ├─────────────┼────────┤ # │ isNpmOrYarn │ false │ # │ isNpm │ false │ # │ isYarn │ false │ # └─────────────┴────────┘ $ npm run foo # ┌────────
is-npm-main.zip
  • is-npm-main
  • .github
  • workflows
  • main.yml
    436B
  • funding.yml
    42B
  • security.md
    179B
  • index.test-d.ts
    170B
  • .gitattributes
    19B
  • test.js
    90B
  • license
    1.1KB
  • index.d.ts
    780B
  • .npmrc
    19B
  • .editorconfig
    175B
  • .gitignore
    23B
  • index.js
    456B
  • readme.md
    1.9KB
  • package.json
    664B
内容介绍
# is-npm > Check if your code is running as an [npm](https://docs.npmjs.com/misc/scripts) or [yarn](https://yarnpkg.com/lang/en/docs/cli/run/) script ## Install ``` $ npm install is-npm ``` ## Usage ```js const {isNpmOrYarn, isNpm, isYarn} = require('is-npm'); console.table({isNpmOrYarn, isNpm, isYarn}); ``` ```sh $ node foo.js # ┌─────────────┬────────┐ # │ (index) │ Values │ # ├─────────────┼────────┤ # │ isNpmOrYarn │ false │ # │ isNpm │ false │ # │ isYarn │ false │ # └─────────────┴────────┘ $ npm run foo # ┌─────────────┬────────┐ # │ (index) │ Values │ # ├─────────────┼────────┤ # │ isNpmOrYarn │ true │ # │ isNpm │ true │ # │ isYarn │ false │ # └─────────────┴────────┘ $ yarn run foo # ┌─────────────┬────────┐ # │ (index) │ Values │ # ├─────────────┼────────┤ # │ isNpmOrYarn │ true │ # │ isNpm │ false │ # │ isYarn │ true │ # └─────────────┴────────┘ ``` ## Related - [is-npm-cli](https://github.com/sindresorhus/is-npm-cli) - CLI for this module --- <div align="center"> <b> <a href="https://tidelift.com/subscription/pkg/npm-is-npm?utm_source=npm-is-npm&utm_medium=referral&utm_campaign=readme" rel='nofollow' onclick='return false;'>Get professional support for this package with a Tidelift subscription</a> </b> <br> <sub> Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. </sub> </div>
评论
    相关推荐