Skip to content

Commit 94c44e3

Browse files
author
Gabriel Schulhof
committed
squash! address review comments
1 parent 882be6d commit 94c44e3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tools/check-napi.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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-9a-f]*)? ([a-zA-Z]) (.*$)/);
4344
line.shift();
4445
if (line[1] === 'U') {
45-
if (line[2].match(/^napi/)) {
46+
if (/^napi/.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-9a-f]*)? +([a-zA-Z0-9]) (.*$)/);
59-
if (line && line[line.length - 1].match(/^napi/)) {
60+
if (line && /^napi/.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(/[.]node$/) &&
78+
} else if (/[.]node$/.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

Comments
 (0)