1+ var common = require ( "../common-tap" )
12var test = require ( "tap" ) . test
23var npm = require . resolve ( "../../bin/npm-cli.js" )
34
4- var spawn = require ( "child_process" ) . spawn
55var node = process . execPath
66
77// ignore-scripts/package.json has scripts that always exit with non-zero error
@@ -10,14 +10,14 @@ var node = process.execPath
1010var pkg = __dirname + "/ignore-scripts"
1111
1212test ( "ignore-scripts: install using the option" , function ( t ) {
13- createChild ( [ npm , "install" , "--ignore-scripts" ] ) . on ( "close" , function ( code ) {
13+ createChild ( [ "install" , "--ignore-scripts" ] , function ( err , code ) {
1414 t . equal ( code , 0 )
1515 t . end ( )
1616 } )
1717} )
1818
1919test ( "ignore-scripts: install NOT using the option" , function ( t ) {
20- createChild ( [ npm , "install" ] ) . on ( "close" , function ( code ) {
20+ createChild ( [ "install" ] , function ( err , code ) {
2121 t . notEqual ( code , 0 )
2222 t . end ( )
2323 } )
@@ -36,24 +36,23 @@ var scripts = [
3636
3737scripts . forEach ( function ( script ) {
3838 test ( "ignore-scripts: run-script " + script + " using the option" , function ( t ) {
39- createChild ( [ npm , "--ignore-scripts" , "run-script" , script ] )
40- . on ( "close" , function ( code ) {
41- t . equal ( code , 0 )
42- t . end ( )
43- } )
39+ createChild ( [ "--ignore-scripts" , "run-script" , script ] , function ( err , code ) {
40+ t . equal ( code , 0 )
41+ t . end ( )
42+ } )
4443 } )
4544} )
4645
4746scripts . forEach ( function ( script ) {
4847 test ( "ignore-scripts: run-script " + script + " NOT using the option" , function ( t ) {
49- createChild ( [ npm , "run-script" , script ] ) . on ( "close" , function ( code ) {
48+ createChild ( [ "run-script" , script ] , function ( err , code ) {
5049 t . notEqual ( code , 0 )
5150 t . end ( )
5251 } )
5352 } )
5453} )
5554
56- function createChild ( args ) {
55+ function createChild ( args , cb ) {
5756 var env = {
5857 HOME : process . env . HOME ,
5958 Path : process . env . PATH ,
@@ -64,9 +63,9 @@ function createChild (args) {
6463 if ( process . platform === "win32" )
6564 env . npm_config_cache = "%APPDATA%\\npm-cache"
6665
67- return spawn ( node , args , {
66+ return common . npm ( args , {
6867 cwd : pkg ,
6968 stdio : "inherit" ,
7069 env : env
71- } )
70+ } , cb )
7271}
0 commit comments