Skip to content

Commit

Permalink
squash! address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed Sep 19, 2018
1 parent 882be6d commit 9c81e5f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tools/check-napi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ function checkFile(file, command, arguments, reducer) {
let isNapi = undefined;
child.stdout.on('data', (chunk) => {
if (isNapi === undefined) {
chunk = leftover + chunk.toString();
const haveLeftover = !!chunk.match(/[\r\n]+$/);
chunk = chunk.split(/[\r\n]+/);
chunk = (leftover + chunk.toString()).split(/[\r\n]+/);
leftover = chunk.pop();
isNapi = chunk.reduce(reducer, isNapi);
if (isNapi !== undefined) {
child.kill();
}
}
});
child.on('exit', (code, signal) => {
child.on('close', (code, signal) => {
if ((code === null && signal !== null) || (code !== 0)) {
console.log(
command + ' exited with code: ' + code + ' and signal: ' + signal);
Expand All @@ -40,9 +41,8 @@ function checkFileUNIX(file) {
checkFile(file, 'nm', ['-a', file], (soFar, line) => {
if (soFar === undefined) {
line = line.match(/([0-9a-f]*)? ([a-zA-Z]) (.*$)/);
line.shift();
if (line[1] === 'U') {
if (line[2].match(/^napi/)) {
if (line[2] === 'U') {
if (/^napi/.test(line[3])) {
soFar = true;
}
}
Expand All @@ -56,7 +56,7 @@ function checkFileWin32(file) {
checkFile(file, 'dumpbin', ['/imports', file], (soFar, line) => {
if (soFar === undefined) {
line = line.match(/([0-9a-f]*)? +([a-zA-Z0-9]) (.*$)/);
if (line && line[line.length - 1].match(/^napi/)) {
if (line && /^napi/.test(line[line.length - 1])) {
soFar = true;
}
}
Expand All @@ -74,7 +74,7 @@ function recurse(top) {
if (!error) {
if (stats.isDirectory()) {
recurse(item);
} else if (item.match(/[.]node$/) &&
} else if (/[.]node$/.test(item) &&
// Explicitly ignore files called 'nothing.node' because they are
// artefacts of node-addon-api having identified a version of
// Node.js that ships with a correct implementation of N-API.
Expand Down

0 comments on commit 9c81e5f

Please sign in to comment.