@@ -4,20 +4,23 @@ module.exports = async process => {
4
4
// leak any private CLI configs to other programs
5
5
process . title = 'npm'
6
6
7
- const { checkForBrokenNode, checkForUnsupportedNode } = require ( '../lib/utils/unsupported.js' )
8
-
7
+ // We used to differentiate between known broken and unsupported
8
+ // versions of node and attempt to only log unsupported but still run.
9
+ // After we dropped node 10 support, we can use new features
10
+ // (like static, private, etc) which will only give vague syntax errors,
11
+ // so now both broken and unsupported use console, but only broken
12
+ // will process.exit. It is important to now perform *both* of these
13
+ // checks as early as possible so the user gets the error message.
14
+ const { checkForBrokenNode, checkForUnsupportedNode } = require ( './utils/unsupported.js' )
9
15
checkForBrokenNode ( )
10
-
11
- const log = require ( 'npmlog' )
12
- // pause it here so it can unpause when we've loaded the configs
13
- // and know what loglevel we should be printing.
14
- log . pause ( )
15
-
16
16
checkForUnsupportedNode ( )
17
17
18
- const Npm = require ( '../lib/npm.js' )
18
+ const exitHandler = require ( './utils/exit-handler.js' )
19
+ process . on ( 'uncaughtException' , exitHandler )
20
+ process . on ( 'unhandledRejection' , exitHandler )
21
+
22
+ const Npm = require ( './npm.js' )
19
23
const npm = new Npm ( )
20
- const exitHandler = require ( '../lib/utils/exit-handler.js' )
21
24
exitHandler . setNpm ( npm )
22
25
23
26
// if npm is called as "npmg" or "npm_g", then
@@ -26,16 +29,14 @@ module.exports = async process => {
26
29
process . argv . splice ( 1 , 1 , 'npm' , '-g' )
27
30
}
28
31
29
- const replaceInfo = require ( '../lib/utils/replace-info.js' )
32
+ const log = require ( './utils/log-shim.js' )
33
+ const replaceInfo = require ( './utils/replace-info.js' )
30
34
log . verbose ( 'cli' , replaceInfo ( process . argv ) )
31
35
32
36
log . info ( 'using' , 'npm@%s' , npm . version )
33
37
log . info ( 'using' , 'node@%s' , process . version )
34
38
35
- process . on ( 'uncaughtException' , exitHandler )
36
- process . on ( 'unhandledRejection' , exitHandler )
37
-
38
- const updateNotifier = require ( '../lib/utils/update-notifier.js' )
39
+ const updateNotifier = require ( './utils/update-notifier.js' )
39
40
40
41
let cmd
41
42
// now actually fire up npm and run the command.
@@ -63,7 +64,7 @@ module.exports = async process => {
63
64
}
64
65
65
66
await npm . exec ( cmd , npm . argv )
66
- exitHandler ( )
67
+ return exitHandler ( )
67
68
} catch ( err ) {
68
69
if ( err . code === 'EUNKNOWNCOMMAND' ) {
69
70
const didYouMean = require ( './utils/did-you-mean.js' )
0 commit comments