Skip to content

Clean up include path and flag-check #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ var versionArray = process.version
var isNodeApiBuiltin =
(versionArray[0] > 8 || (versionArray[0] == 8 && versionArray[1] > 5));

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

var include = path.join(__dirname, 'src');
var include = [__dirname];
var gyp = path.join(__dirname, 'src', 'node_api.gyp');

if (isNodeApiBuiltin) {
gyp += ':nothing';
gyp += ':nothing';
} else {
gyp += ':node-api';
include = path.join(__dirname, 'external-napi');
gyp += ':node-api';
include.unshift(path.join(__dirname, 'external-napi'));
}

module.exports = {
include: [ '"' + include + '"', '"' + __dirname + '"' ].join(' '),
gyp: gyp,
isNodeApiBuiltin: isNodeApiBuiltin,
needsFlag: needsFlag
include: include.map(function(item) {
return '"' + item + '"';
}).join(' '),
gyp: gyp,
isNodeApiBuiltin: isNodeApiBuiltin,
needsFlag: needsFlag
};