diff --git a/index.js b/index.js index 4877abc97..e235cc3e9 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,5 @@ const path = require('path'); +const { version } = require('./package.json'); const includeDir = path.relative('.', __dirname); @@ -7,6 +8,7 @@ module.exports = { include_dir: includeDir, gyp: path.join(includeDir, 'node_api.gyp:nothing'), // deprecated. targets: path.join(includeDir, 'node_addon_api.gyp'), + version, isNodeApiBuiltin: true, needsFlag: false }; diff --git a/package.json b/package.json index 525d6cf69..e63fee833 100644 --- a/package.json +++ b/package.json @@ -431,7 +431,8 @@ "fs-extra": "^11.1.1", "path": "^0.12.7", "pre-commit": "^1.2.2", - "safe-buffer": "^5.1.1" + "safe-buffer": "^5.1.1", + "semver": "^7.6.0" }, "directories": {}, "gypfile": false, diff --git a/test/exports.js b/test/exports.js new file mode 100644 index 000000000..1aa39281c --- /dev/null +++ b/test/exports.js @@ -0,0 +1,19 @@ +'use strict'; + +const { strictEqual } = require('assert'); +const { valid } = require('semver'); + +const nodeAddonApi = require('../'); + +module.exports = function test () { + strictEqual(nodeAddonApi.include.startsWith('"'), true); + strictEqual(nodeAddonApi.include.endsWith('"'), true); + strictEqual(nodeAddonApi.include.includes('node-addon-api'), true); + strictEqual(nodeAddonApi.include_dir, ''); + strictEqual(nodeAddonApi.gyp, 'node_api.gyp:nothing'); + strictEqual(nodeAddonApi.targets, 'node_addon_api.gyp'); + strictEqual(valid(nodeAddonApi.version), true); + strictEqual(nodeAddonApi.version, require('../package.json').version); + strictEqual(nodeAddonApi.isNodeApiBuiltin, true); + strictEqual(nodeAddonApi.needsFlag, false); +}; diff --git a/tools/conversion.js b/tools/conversion.js index f89245ac6..e92a03a26 100755 --- a/tools/conversion.js +++ b/tools/conversion.js @@ -12,7 +12,7 @@ if (!dir) { process.exit(1); } -const NodeApiVersion = require('../package.json').version; +const NodeApiVersion = require('../').version; const disable = args[1]; let ConfigFileOperations;