From 7d52b198cc7f587511bd577d725faa7560250da2 Mon Sep 17 00:00:00 2001 From: Nicola Del Gobbo Date: Wed, 29 Mar 2023 17:53:42 +0200 Subject: [PATCH 1/2] fix: moved def files on a proper folder. --- README.md | 6 ++++++ index.js | 8 +++++++- scripts/write-win32-def.js | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6779b43..72137a5 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,12 @@ The module exports two properties `include_dir` and `symbols`. This property is a string that represents the include path for the Node-API headers. +### `def` + +This property is an object that has two keys `js_native_api_def` and +`node_api_def` which represents the path of the module definition file for the +`js_native_api` and `node_api` respectively. + ### `symbols` This property is an object that represents the symbols exported by Node-API diff --git a/index.js b/index.js index 83c7ea2..278b53d 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,17 @@ 'use strict' const path = require('path'); -const symbols = require('./symbols') +const symbols = require('./symbols'); const include_dir = path.resolve(__dirname, 'include'); +const defRoot = path.resolve(__dirname, 'def') +const def = { + js_native_api_def: path.join(defRoot, 'js_native_api.def'), + node_api_def: path.join(defRoot, 'node_api.def') +} module.exports = { include_dir, + def, symbols } diff --git a/scripts/write-win32-def.js b/scripts/write-win32-def.js index 5a8bc54..1333bce 100644 --- a/scripts/write-win32-def.js +++ b/scripts/write-win32-def.js @@ -1,7 +1,7 @@ 'use strict'; -const { resolve: resolvePath } = require('path'); -const { writeFile } = require('fs/promises'); +const { resolve: resolvePath, join: joinPath } = require('path'); +const { writeFile, mkdir } = require('fs/promises'); const { symbols } = require('..'); function getNodeApiDef() { @@ -28,11 +28,20 @@ function getJsNativeApiDef() { } async function main() { - const nodeApiDefPath = resolvePath(__dirname, '../node_api.def'); + const def = resolvePath(__dirname, '../def'); + try { + await mkdir(def) + } catch (e) { + if (e.code !== 'EEXIST') { + throw e; + } + } + + const nodeApiDefPath = joinPath(def, 'node_api.def'); console.log(`Writing Windows .def file to ${nodeApiDefPath}`); await writeFile(nodeApiDefPath, getNodeApiDef()); - const jsNativeApiDefPath = resolvePath(__dirname, '../js_native_api.def'); + const jsNativeApiDefPath = joinPath(def, 'js_native_api.def'); console.log(`Writing Windows .def file to ${jsNativeApiDefPath}`); await writeFile(jsNativeApiDefPath, getJsNativeApiDef()); } From 925dc73d7dc0f1cea2528318d6650a7f76930de4 Mon Sep 17 00:00:00 2001 From: Nicola Del Gobbo Date: Fri, 31 Mar 2023 10:42:42 +0200 Subject: [PATCH 2/2] fixed as requested. --- README.md | 2 +- index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 72137a5..3cb98b0 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The module exports two properties `include_dir` and `symbols`. This property is a string that represents the include path for the Node-API headers. -### `def` +### `def_paths` This property is an object that has two keys `js_native_api_def` and `node_api_def` which represents the path of the module definition file for the diff --git a/index.js b/index.js index 278b53d..d9123bb 100644 --- a/index.js +++ b/index.js @@ -5,13 +5,13 @@ const symbols = require('./symbols'); const include_dir = path.resolve(__dirname, 'include'); const defRoot = path.resolve(__dirname, 'def') -const def = { +const def_paths = { js_native_api_def: path.join(defRoot, 'js_native_api.def'), node_api_def: path.join(defRoot, 'node_api.def') } module.exports = { include_dir, - def, + def_paths, symbols }