@@ -5,6 +5,7 @@ import { realpathSync } from 'node:fs'
55import path from 'node:path'
66
77import { installLinks } from './link'
8+ import { findRoot } from '../utils/path-resolve'
89
910const realFilename = realpathSync ( __filename )
1011const realDirname = path . dirname ( realFilename )
@@ -14,9 +15,32 @@ const injectionPath = path.join(realDirname, 'npm-injection.js')
1415
1516process . exitCode = 1
1617
18+ /*
19+ Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
20+ is found to fix a UX issue when running the command with recent versions of npm
21+ (input swallowed by the standard npm spinner)
22+ */
23+ let npmArgs : string [ ] = [ ]
24+ if ( process . argv . slice ( 2 ) . includes ( 'install' ) ) {
25+ const npmEntrypoint = realpathSync ( npmPath )
26+ const npmRootPath = findRoot ( path . dirname ( npmEntrypoint ) )
27+ if ( npmRootPath === undefined ) {
28+ process . exit ( 127 )
29+ }
30+ const npmDepPath = path . join ( npmRootPath , 'node_modules' )
31+
32+ let npmlog
33+ try {
34+ npmlog = require ( path . join ( npmDepPath , 'proc-log/lib/index.js' ) ) . log
35+ } catch { }
36+ if ( npmlog ) {
37+ npmArgs = [ '--quiet' , '--no-progress' ]
38+ }
39+ }
40+
1741spawn (
1842 process . execPath ,
19- [ '--require' , injectionPath , npmPath , ...process . argv . slice ( 2 ) ] ,
43+ [ '--require' , injectionPath , npmPath , ...process . argv . slice ( 2 ) , ... npmArgs ] ,
2044 {
2145 stdio : 'inherit'
2246 }
0 commit comments