npm-cli-path
Advanced tools
Comparing version 2.0.1 to 2.0.3
54
index.js
@@ -1,5 +0,1 @@ | ||
/*! | ||
* npm-cli-path | MIT (c) Shinnosuke Watanabe | ||
* https://github.com/shinnn/npm-cli-path | ||
*/ | ||
'use strict'; | ||
@@ -12,36 +8,34 @@ | ||
if (process.platform !== 'win32') { | ||
module.exports = function npmCliPath() { | ||
return getNpmCliPath; | ||
}; | ||
module.exports = function npmCliPath() { | ||
return getNpmCliPath; | ||
}; | ||
} else { | ||
const pathLib = require('path'); | ||
const pathLib = require('path'); | ||
const dirname = pathLib.dirname; | ||
const join = pathLib.join; | ||
const dirname = pathLib.dirname; | ||
const join = pathLib.join; | ||
const winUserInstalledNpmCliPath = require('win-user-installed-npm-cli-path'); | ||
const winUserInstalledNpmCliPath = require('win-user-installed-npm-cli-path'); | ||
const getPreinstalledNpmCliPath = getNpmCliPath.then(cmdPath => { | ||
return join(dirname(cmdPath), 'node_modules\\npm\\bin\\npm-cli.js'); | ||
}); | ||
const getPreinstalledNpmCliPath = getNpmCliPath.then(cmdPath => join(dirname(cmdPath), 'node_modules\\npm\\bin\\npm-cli.js')); | ||
const getUserInstalledCliPath = winUserInstalledNpmCliPath() | ||
.then(Promise.resolve.bind(Promise), err => { | ||
if (/lstat .*\\node_modules\\npm\\bin\\npm-cli\.js/.test(err.message)) { | ||
return null; | ||
} | ||
const getUserInstalledCliPath = winUserInstalledNpmCliPath() | ||
.then(Promise.resolve.bind(Promise), err => { | ||
if (/lstat .*\\node_modules\\npm\\bin\\npm-cli\.js/.test(err.message)) { | ||
return null; | ||
} | ||
return Promise.reject(err); | ||
}); | ||
return Promise.reject(err); | ||
}); | ||
module.exports = function npmCliPath() { | ||
return Promise.all([ | ||
getPreinstalledNpmCliPath, | ||
getUserInstalledCliPath | ||
]).then(results => { | ||
const userInstalledCliPath = results[1]; | ||
module.exports = function npmCliPath() { | ||
return Promise.all([ | ||
getPreinstalledNpmCliPath, | ||
getUserInstalledCliPath | ||
]).then(results => { | ||
const userInstalledCliPath = results[1]; | ||
return userInstalledCliPath || results[0]; | ||
}); | ||
}; | ||
return userInstalledCliPath || results[0]; | ||
}); | ||
}; | ||
} |
{ | ||
"name": "npm-cli-path", | ||
"version": "2.0.1", | ||
"description": "Resolve the path of `npm-cli.js` included in the globally installed npm CLI", | ||
"repository": "shinnn/npm-cli-path", | ||
"author": "Shinnosuke Watanabe (https://github.com/shinnn)", | ||
"scripts": { | ||
"pretest": "eslint --fix --format=codeframe index.js tests", | ||
"test": "istanbul cover --dir=coverage/0 tests/no-npm.js && istanbul cover --dir=coverage/1 tests/posix.js", | ||
"coveralls": "istanbul report lcov && istanbul-coveralls" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"npm", | ||
"npm-cli", | ||
"cli", | ||
"path", | ||
"bin", | ||
"entry", | ||
"entry-point", | ||
"file", | ||
"find", | ||
"pinpoint", | ||
"resolve", | ||
"promise", | ||
"promises", | ||
"then", | ||
"async", | ||
"asynchronous", | ||
"asynchronously" | ||
], | ||
"dependencies": { | ||
"real-executable-path": "^2.0.1", | ||
"win-user-installed-npm-cli-path": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^4.0.2", | ||
"eslint": "^4.11.0", | ||
"graceful-fs": "^4.1.11", | ||
"istanbul": "^0.4.5", | ||
"istanbul-coveralls": "^1.0.3", | ||
"pify": "^3.0.0", | ||
"pretend-platform": "^2.0.0", | ||
"tape": "^4.8.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@shinnn/node" | ||
} | ||
"name": "npm-cli-path", | ||
"version": "2.0.3", | ||
"description": "Resolve the path of `npm-cli.js` included in the globally installed npm CLI", | ||
"repository": "shinnn/npm-cli-path", | ||
"author": "Shinnosuke Watanabe (https://github.com/shinnn)", | ||
"scripts": { | ||
"pretest": "eslint --fix --format=codeframe index.js tests", | ||
"test": "istanbul cover --dir=coverage/0 tests/no-npm.js && istanbul cover --dir=coverage/1 tests/posix.js", | ||
"coveralls": "istanbul report lcov && npx istanbul-coveralls" | ||
}, | ||
"license": "ISC", | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"npm", | ||
"npm-cli", | ||
"cli", | ||
"path", | ||
"bin", | ||
"entry", | ||
"entry-point", | ||
"file", | ||
"find", | ||
"pinpoint", | ||
"resolve", | ||
"promise", | ||
"promises", | ||
"then", | ||
"async", | ||
"asynchronous", | ||
"asynchronously" | ||
], | ||
"dependencies": { | ||
"real-executable-path": "^2.0.2", | ||
"win-user-installed-npm-cli-path": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^5.0.0", | ||
"eslint": "^4.16.0", | ||
"graceful-fs": "^4.1.11", | ||
"istanbul": "^0.4.5", | ||
"pretend-platform": "^2.0.0", | ||
"tape": "^4.8.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@shinnn/node" | ||
} | ||
} |
# npm-cli-path | ||
[![NPM version](https://img.shields.io/npm/v/npm-cli-path.svg)](https://www.npmjs.com/package/npm-cli-path) | ||
[![npm version](https://img.shields.io/npm/v/npm-cli-path.svg)](https://www.npmjs.com/package/npm-cli-path) | ||
[![Build Status](https://travis-ci.org/shinnn/npm-cli-path.svg?branch=master)](https://travis-ci.org/shinnn/npm-cli-path) | ||
@@ -13,5 +13,5 @@ [![Build status](https://ci.appveyor.com/api/projects/status/8osd3at404d3jrxi/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/npm-cli-path/branch/master) | ||
npmCliPath().then(result => { | ||
result; //=> '/usr/local/lib/node_modules/npm/bin/npm-cli.js' | ||
}); | ||
(async () => { | ||
const path = npmCliPath(); //=> '/usr/local/lib/node_modules/npm/bin/npm-cli.js' | ||
})(); | ||
``` | ||
@@ -21,3 +21,3 @@ | ||
[Use npm.](https://docs.npmjs.com/cli/install) | ||
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm). | ||
@@ -36,3 +36,3 @@ ``` | ||
Return: [`Promise`](http://www.ecma-international.org/ecma-262/6.0/#sec-promise-constructor) instance | ||
Return: `Promise<string>` | ||
@@ -43,6 +43,4 @@ It resolves the path of [`npm-cli.js`][npm-cli] which is the entry point of [npm](https://github.com/npm/npm) CLI. | ||
Copyright (c) 2015 - 2017 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
[ISC License](./LICENSE) © 2017 - 2018 Shinnosuke Watanabe | ||
Licensed under [the MIT License](./LICENSE). | ||
[npm-cli]: https://github.com/npm/npm/blob/master/bin/npm-cli.js |
Sorry, the diff of this file is not supported yet
6
4299
30
43
Updatedreal-executable-path@^2.0.2