Skip to content

fix: moved def files on a proper folder. #19

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

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_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
`js_native_api` and `node_api` respectively.

### `symbols`

This property is an object that represents the symbols exported by Node-API
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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_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_paths,
symbols
}
17 changes: 13 additions & 4 deletions scripts/write-win32-def.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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());
}
Expand Down