Skip to content

Commit 09bca93

Browse files
author
Gabriel Schulhof
committed
Clean up include path and flag-check
node_api.h must be included from the normal node include path when we can use the built-in API. The variable needsFlag must be true from version 8.0.0 inclusive until version 8.6.0 non-inclusive. Fixes: #139
1 parent 82c2fa5 commit 09bca93

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,27 @@ var versionArray = process.version
1717
var isNodeApiBuiltin =
1818
(versionArray[0] > 8 || (versionArray[0] == 8 && versionArray[1] > 5));
1919

20-
// So far it looks like even version 9 will need the flag. We need to adjust
21-
// this for the version where the flag is dropped whenever that version lands.
22-
var needsFlag = (versionArray[0] >= 8);
20+
// The flag is not needed when the Node version is not 8, nor if the API is
21+
// built-in, because we removed the flag at the same time as creating the final
22+
// incarnation of the built-in API.
23+
var needsFlag =
24+
!(isNodeApiBuiltin || versionArray[0] < 8 || versionArray[0] > 8);
2325

24-
var include = path.join(__dirname, 'src');
26+
var include = [];
2527
var gyp = path.join(__dirname, 'src', 'node_api.gyp');
2628

2729
if (isNodeApiBuiltin) {
2830
gyp += ':nothing';
2931
} else {
30-
gyp += ':node-api';
31-
include = path.join(__dirname, 'external-napi');
32+
gyp += ':node-api';
33+
include = [
34+
'"' + path.join(__dirname, 'external-napi') + '"',
35+
'"' + __dirname + '"'
36+
];
3237
}
3338

3439
module.exports = {
35-
include: [ '"' + include + '"', '"' + __dirname + '"' ].join(' '),
40+
include: include.join(' '),
3641
gyp: gyp,
3742
isNodeApiBuiltin: isNodeApiBuiltin,
3843
needsFlag: needsFlag

0 commit comments

Comments
 (0)