is-npm
Advanced tools
Comparing version 4.0.0 to 5.0.0
'use strict'; | ||
const packageJson = process.env.npm_package_json; | ||
const userAgent = process.env.npm_config_user_agent; | ||
const isYarn = Boolean(userAgent && userAgent.startsWith('yarn')); | ||
const isNpm = Boolean(userAgent && userAgent.startsWith('npm')); | ||
const isNpm7 = Boolean(packageJson && packageJson.endsWith('package.json')); | ||
module.exports.isNpmOrYarn = isNpm || isYarn; | ||
module.exports.isNpm = isNpm; | ||
module.exports.isNpmOrYarn = isNpm || isNpm7 || isYarn; | ||
module.exports.isNpm = isNpm || isNpm7; | ||
module.exports.isYarn = isYarn; |
{ | ||
"name": "is-npm", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Check if your code is running as an npm script", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-npm", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -24,2 +25,3 @@ "files": [ | ||
"npm", | ||
"yarn", | ||
"is", | ||
@@ -35,5 +37,5 @@ "check", | ||
"ava": "^2.4.0", | ||
"tsd-check": "^0.6.0", | ||
"xo": "^0.25.3" | ||
"tsd": "^0.11.0", | ||
"xo": "^0.30.0" | ||
} | ||
} |
@@ -1,6 +0,5 @@ | ||
# is-npm [![Build Status](https://travis-ci.org/sindresorhus/is-npm.svg?branch=master)](https://travis-ci.org/sindresorhus/is-npm) | ||
# is-npm [![Build Status](https://travis-ci.com/sindresorhus/is-npm.svg?branch=master)](https://travis-ci.com/sindresorhus/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 | ||
@@ -12,3 +11,2 @@ | ||
## Usage | ||
@@ -49,3 +47,6 @@ | ||
## Related | ||
- [is-npm-cli](https://github.com/sindresorhus/is-npm-cli) - CLI for this module | ||
--- | ||
@@ -52,0 +53,0 @@ |
Sorry, the diff of this file is not supported yet
5104
42
61