Skip to content

Commit ea0dc01

Browse files
authored
fix: moved def files on a proper folder. (#19)
1 parent 069c3eb commit ea0dc01

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ The module exports two properties `include_dir` and `symbols`.
5151
This property is a string that represents the include path for the Node-API
5252
headers.
5353

54+
### `def_paths`
55+
56+
This property is an object that has two keys `js_native_api_def` and
57+
`node_api_def` which represents the path of the module definition file for the
58+
`js_native_api` and `node_api` respectively.
59+
5460
### `symbols`
5561

5662
This property is an object that represents the symbols exported by Node-API

index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
'use strict'
22

33
const path = require('path');
4-
const symbols = require('./symbols')
4+
const symbols = require('./symbols');
55

66
const include_dir = path.resolve(__dirname, 'include');
7+
const defRoot = path.resolve(__dirname, 'def')
8+
const def_paths = {
9+
js_native_api_def: path.join(defRoot, 'js_native_api.def'),
10+
node_api_def: path.join(defRoot, 'node_api.def')
11+
}
712

813
module.exports = {
914
include_dir,
15+
def_paths,
1016
symbols
1117
}

scripts/write-win32-def.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const { resolve: resolvePath } = require('path');
4-
const { writeFile } = require('fs/promises');
3+
const { resolve: resolvePath, join: joinPath } = require('path');
4+
const { writeFile, mkdir } = require('fs/promises');
55
const { symbols } = require('..');
66

77
function getNodeApiDef() {
@@ -28,11 +28,20 @@ function getJsNativeApiDef() {
2828
}
2929

3030
async function main() {
31-
const nodeApiDefPath = resolvePath(__dirname, '../node_api.def');
31+
const def = resolvePath(__dirname, '../def');
32+
try {
33+
await mkdir(def)
34+
} catch (e) {
35+
if (e.code !== 'EEXIST') {
36+
throw e;
37+
}
38+
}
39+
40+
const nodeApiDefPath = joinPath(def, 'node_api.def');
3241
console.log(`Writing Windows .def file to ${nodeApiDefPath}`);
3342
await writeFile(nodeApiDefPath, getNodeApiDef());
3443

35-
const jsNativeApiDefPath = resolvePath(__dirname, '../js_native_api.def');
44+
const jsNativeApiDefPath = joinPath(def, 'js_native_api.def');
3645
console.log(`Writing Windows .def file to ${jsNativeApiDefPath}`);
3746
await writeFile(jsNativeApiDefPath, getJsNativeApiDef());
3847
}

0 commit comments

Comments
 (0)