Skip to content

Commit

Permalink
remove N-API implementation
Browse files Browse the repository at this point in the history
Remove the files associated with the external implementation of N-API.
Making this move is possible because all supported versions of Node.js
now have an internal implementation of N-API.

Fixes: nodejs#463
Fixes: nodejs#509
  • Loading branch information
Gabriel Schulhof committed Jan 1, 2020
1 parent 5eeabb0 commit fea8e93
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 4,749 deletions.
7 changes: 0 additions & 7 deletions external-napi/node_api.h

This file was deleted.

47 changes: 5 additions & 42 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
var path = require('path');

var versionArray = process.version
.substr(1)
.replace(/-.*$/, '')
.split('.')
.map(function(item) {
return +item;
});

// TODO: Check if the main node semantic version is within multiple ranges,
// or detect presence of built-in N-API by some other mechanism TBD.

// We know which version of Node.js first shipped the incarnation of the API
// available in *this* package. So, if we find that the Node.js version is below
// that, we indicate that the API is missing from Node.js.
var isNodeApiBuiltin = (
versionArray[0] > 8 ||
(versionArray[0] == 8 && versionArray[1] >= 6) ||
(versionArray[0] == 6 && versionArray[1] >= 15) ||
(versionArray[0] == 6 && versionArray[1] >= 14 && versionArray[2] >= 2));

// 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 = [__dirname];
var gyp = path.join(__dirname, 'src', 'node_api.gyp');

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

module.exports = {
include: include.map(function(item) {
return '"' + item + '"';
}).join(' '),
gyp: gyp,
isNodeApiBuiltin: isNodeApiBuiltin,
needsFlag: needsFlag
include: `"${__dirname}"`,
gyp: path.join(__dirname, 'src', 'node_api.gyp:nothing'),
isNodeApiBuiltin: true,
needsFlag: false
};
4 changes: 0 additions & 4 deletions src/.gitignore

This file was deleted.

Loading

0 comments on commit fea8e93

Please sign in to comment.