You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/cli.js
+4-32Lines changed: 4 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,7 @@
1
1
/* eslint-disable max-len */
2
-
// Code in this file should work in all conceivably runnable versions of node.
3
-
// A best effort is made to catch syntax errors to give users a good error message if they are using a node version that doesn't allow syntax we are using in other files such as private properties, etc
4
2
5
3
// Separated out for easier unit testing
6
-
module.exports=asyncprocess=>{
4
+
module.exports=async(process,validateEngines)=>{
7
5
// set it here so that regardless of what happens later, we don't
8
6
// leak any private CLI configs to other programs
9
7
process.title='npm'
@@ -13,31 +11,6 @@ module.exports = async process => {
constunsupportedMessage=`npm ${npmVersion} does not support Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
22
-
23
-
constbrokenMessage=`ERROR: npm ${npmVersion} is known not to run on Node.js ${nodeVersion}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
24
-
25
-
// Coverage ignored because this is only hit in very unsupported node versions and it's a best effort attempt to show something nice in those cases
@@ -51,14 +24,13 @@ module.exports = async process => {
51
24
log.info('using','node@%s',process.version)
52
25
53
26
// At this point we've required a few files and can be pretty sure we dont contain invalid syntax for this version of node. It's possible a lazy require would, but that's unlikely enough that it's not worth catching anymore and we attach the more important exit handlers.
// It is now safe to log a warning if they are using a version of node that is not going to fail on syntax errors but is still unsupported and untested and might not work reliably. This is safe to use the logger now which we want since this will show up in the error log too.
// This is separate to indicate that it should contain code we expect to work in
2
+
// all versions of node >= 6. This is a best effort to catch syntax errors to
3
+
// give users a good error message if they are using a node version that doesn't
4
+
// allow syntax we are using such as private properties, etc. This file is
5
+
// linted with ecmaVersion=6 so we don't use invalid syntax, which is set in the
6
+
// .eslintrc.local.json file
7
+
8
+
const{engines: {node: engines}, version }=require('../../package.json')
9
+
constnpm=`v${version}`
10
+
11
+
module.exports=(process,getCli)=>{
12
+
constnode=process.version.replace(/-.*$/,'')
13
+
14
+
/* eslint-disable-next-line max-len */
15
+
constunsupportedMessage=`npm ${npm} does not support Node.js ${node}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
16
+
17
+
/* eslint-disable-next-line max-len */
18
+
constbrokenMessage=`ERROR: npm ${npm} is known not to run on Node.js ${node}. This version of npm supports the following node versions: \`${engines}\`. You can find the latest version at https://nodejs.org/.`
19
+
20
+
// coverage ignored because this is only hit in very unsupported node versions
21
+
// and it's a best effort attempt to show something nice in those cases
unsupportedMessage: 'npm v1.2.3 does not support Node.js v4.5.6. This version of npm supports the following node versions: `>=0`. You can find the latest version at https://nodejs.org/.',
0 commit comments