@@ -15,14 +15,15 @@ function checkFile(file, command, arguments, reducer) {
1515 let isNapi = undefined ;
1616 child . stdout . on ( 'data' , ( chunk ) => {
1717 if ( isNapi === undefined ) {
18- chunk = leftover + chunk . toString ( ) ;
19- const haveLeftover = ! ! chunk . match ( / [ \r \n ] + $ / ) ;
20- chunk = chunk . split ( / [ \r \n ] + / ) ;
18+ chunk = ( leftover + chunk . toString ( ) ) . split ( / [ \r \n ] + / ) ;
2119 leftover = chunk . pop ( ) ;
2220 isNapi = chunk . reduce ( reducer , isNapi ) ;
21+ if ( isNapi !== undefined ) {
22+ child . kill ( ) ;
23+ }
2324 }
2425 } ) ;
25- child . on ( 'exit ' , ( code , signal ) => {
26+ child . on ( 'close ' , ( code , signal ) => {
2627 if ( ( code === null && signal !== null ) || ( code !== 0 ) ) {
2728 console . log (
2829 command + ' exited with code: ' + code + ' and signal: ' + signal ) ;
@@ -42,7 +43,7 @@ function checkFileUNIX(file) {
4243 line = line . match ( / ( [ 0 - 9 a - f ] * ) ? ( [ a - z A - Z ] ) ( .* $ ) / ) ;
4344 line . shift ( ) ;
4445 if ( line [ 1 ] === 'U' ) {
45- if ( line [ 2 ] . match ( / ^ n a p i / ) ) {
46+ if ( / ^ n a p i / . test ( line [ 2 ] ) ) {
4647 soFar = true ;
4748 }
4849 }
@@ -56,7 +57,7 @@ function checkFileWin32(file) {
5657 checkFile ( file , 'dumpbin' , [ '/imports' , file ] , ( soFar , line ) => {
5758 if ( soFar === undefined ) {
5859 line = line . match ( / ( [ 0 - 9 a - f ] * ) ? + ( [ a - z A - Z 0 - 9 ] ) ( .* $ ) / ) ;
59- if ( line && line [ line . length - 1 ] . match ( / ^ n a p i / ) ) {
60+ if ( line && / ^ n a p i / . test ( line [ line . length - 1 ] ) ) {
6061 soFar = true ;
6162 }
6263 }
@@ -74,7 +75,7 @@ function recurse(top) {
7475 if ( ! error ) {
7576 if ( stats . isDirectory ( ) ) {
7677 recurse ( item ) ;
77- } else if ( item . match ( / [ . ] n o d e $ / ) &&
78+ } else if ( / [ . ] n o d e $ / . test ( item ) &&
7879 // Explicitly ignore files called 'nothing.node' because they are
7980 // artefacts of node-addon-api having identified a version of
8081 // Node.js that ships with a correct implementation of N-API.
0 commit comments