Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-06-22 00:41:31 +0300
committerGar <gar+gh@danger.computer>2021-06-23 19:34:58 +0300
commitd0f50b156725e5b414050d9e9a59d5fad8a39a3d (patch)
tree4ddbafd360b2f1532c7425169c9c067d5c21f92e /lib/cli.js
parent54eae3063eeb197225ee930525a1316e34ecf34c (diff)
chore(refactor): async npm.load
Tests for cli now use the real npm PR-URL: https://github.com/npm/cli/pull/3451 Credit: @wraithgar Close: #3451 Reviewed-by: @nlf
Diffstat (limited to 'lib/cli.js')
-rw-r--r--lib/cli.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/cli.js b/lib/cli.js
index 106dd629d..9544f8451 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -1,5 +1,5 @@
// Separated out for easier unit testing
-module.exports = (process) => {
+module.exports = async (process) => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title = 'npm'
@@ -39,12 +39,8 @@ module.exports = (process) => {
// now actually fire up npm and run the command.
// this is how to use npm programmatically:
- npm.load(async er => {
- // Any exceptions here will be picked up by the uncaughtException handler
- if (er)
- return exitHandler(er)
-
- // npm --version=cli
+ try {
+ await npm.load()
if (npm.config.get('version', 'cli')) {
npm.output(npm.version)
return exitHandler()
@@ -75,5 +71,7 @@ module.exports = (process) => {
}
impl(npm.argv, exitHandler)
- })
+ } catch (err) {
+ return exitHandler(err)
+ }
}