@@ -4,7 +4,7 @@ if (!common.hasCrypto)
4
4
common . skip ( 'missing crypto' ) ;
5
5
6
6
const path = require ( 'path' ) ;
7
- const spawn = require ( 'child_process' ) . spawn ;
7
+ const exec = require ( 'child_process' ) . exec ;
8
8
const assert = require ( 'assert' ) ;
9
9
const fs = require ( 'fs' ) ;
10
10
@@ -24,11 +24,6 @@ const npmPath = path.join(
24
24
'npm-cli.js'
25
25
) ;
26
26
27
- const args = [
28
- npmPath ,
29
- 'install'
30
- ] ;
31
-
32
27
const pkgContent = JSON . stringify ( {
33
28
dependencies : {
34
29
'package-name' : `${ common . fixturesDir } /packages/main`
@@ -45,17 +40,22 @@ env['NPM_CONFIG_PREFIX'] = path.join(npmSandbox, 'npm-prefix');
45
40
env [ 'NPM_CONFIG_TMP' ] = path . join ( npmSandbox , 'npm-tmp' ) ;
46
41
env [ 'HOME' ] = path . join ( npmSandbox , 'home' ) ;
47
42
48
- const proc = spawn ( process . execPath , args , {
43
+ exec ( ` ${ process . execPath } ${ npmPath } install` , {
49
44
cwd : installDir ,
50
45
env : env
51
- } ) ;
46
+ } , common . mustCall ( handleExit ) ) ;
47
+
48
+ function handleExit ( error , stdout , stderr ) {
49
+ const code = error ? error . code : 0 ;
50
+ const signalCode = error ? error . signal : null ;
51
+
52
+ if ( code !== 0 ) {
53
+ process . stderr . write ( stderr ) ;
54
+ }
52
55
53
- function handleExit ( code , signalCode ) {
54
56
assert . strictEqual ( code , 0 , `npm install got error code ${ code } ` ) ;
55
57
assert . strictEqual ( signalCode , null , `unexpected signal: ${ signalCode } ` ) ;
56
58
assert . doesNotThrow ( function ( ) {
57
59
fs . accessSync ( `${ installDir } /node_modules/package-name` ) ;
58
60
} ) ;
59
61
}
60
-
61
- proc . on ( 'exit' , common . mustCall ( handleExit ) ) ;
0 commit comments