is-npm

Check if your code is running as an npm script


Keywords
npm, yarn, is, check, detect, env, environment, run, script
License
MIT
Install
npm install is-npm@6.0.0

Documentation

is-npm

Check if your code is running as an npm or yarn script

Install

npm install is-npm

Usage

import {isNpmOrYarn, isNpm, isYarn} from 'is-npm';

console.table({isNpmOrYarn, isNpm, isYarn});
$ 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


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.