Socket
Socket
Sign inDemoInstall

npm-cli-path

Package Overview
Dependencies
8
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

58

index.js
'use strict';
const realExecutablePath = require('real-executable-path');
const executingNpmPath = require('executing-npm-path');
const getNpmCliPath = realExecutablePath('npm');
if (process.platform !== 'win32') {
if (executingNpmPath) {
module.exports = async function npmCliPath() {
return getNpmCliPath;
return executingNpmPath;
};
} else {
const {dirname, join} = require('path');
const realExecutablePath = require('real-executable-path');
const winUserInstalledNpmCliPath = require('win-user-installed-npm-cli-path');
const getNpmCliPath = realExecutablePath('npm');
const getPreinstalledNpmCliPath = (async () => join(dirname(await getNpmCliPath), 'node_modules\\npm\\bin\\npm-cli.js'))();
const getUserInstalledCliPath = (async () => {
try {
return await winUserInstalledNpmCliPath();
} catch (err) {
if (/lstat .*\\node_modules\\npm\\bin\\npm-cli\.js/.test(err.message)) {
return null;
if (process.platform !== 'win32') {
module.exports = async function npmCliPath() {
return getNpmCliPath;
};
} else {
const {dirname, join} = require('path');
const winUserInstalledNpmCliPath = require('win-user-installed-npm-cli-path');
const getPreinstalledNpmCliPath = (async () => join(dirname(await getNpmCliPath), 'node_modules\\npm\\bin\\npm-cli.js'))();
const getUserInstalledCliPath = (async () => {
try {
return await winUserInstalledNpmCliPath();
} catch (err) {
if (/lstat .*\\node_modules\\npm\\bin\\npm-cli\.js/.test(err.message)) {
return null;
}
throw err;
}
})();
throw err;
}
})();
module.exports = async function npmCliPath() {
const [preinstalledCliPath, userInstalledCliPath] = await Promise.all([
getPreinstalledNpmCliPath,
getUserInstalledCliPath
]);
module.exports = async function npmCliPath() {
const [preinstalledCliPath, userInstalledCliPath] = await Promise.all([
getPreinstalledNpmCliPath,
getUserInstalledCliPath
]);
return userInstalledCliPath || preinstalledCliPath;
};
return userInstalledCliPath || preinstalledCliPath;
};
}
}
{
"name": "npm-cli-path",
"version": "3.0.0",
"version": "3.1.0",
"description": "Resolve the path of `npm-cli.js` included in the globally installed npm CLI",

@@ -9,3 +9,4 @@ "repository": "shinnn/npm-cli-path",

"pretest": "eslint --fix --format=codeframe index.js tests",
"test": "nyc --clean node tests/no-npm.js && nyc node tests/posix.js && nyc report --reporter=html --reporter=text"
"test": "nyc --clean node tests/no-npm.js && nyc node tests/posix.js && npm run-script test-npm-run --silent && nyc report --reporter=html --reporter=text",
"test-npm-run": "nyc node tests/npm-run-script.js"
},

@@ -36,2 +37,3 @@ "license": "ISC",

"dependencies": {
"executing-npm-path": "^1.0.0",
"real-executable-path": "^3.0.0",

@@ -45,3 +47,3 @@ "win-user-installed-npm-cli-path": "^3.0.0"

"pretend-platform": "^2.0.0",
"tape": "^4.9.0"
"tape": "^4.9.1"
},

@@ -48,0 +50,0 @@ "eslintConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc