File tree 3 files changed +26
-5
lines changed
3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,12 @@ The module exports two properties `include_dir` and `symbols`.
51
51
This property is a string that represents the include path for the Node-API
52
52
headers.
53
53
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
+
54
60
### ` symbols `
55
61
56
62
This property is an object that represents the symbols exported by Node-API
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
3
const path = require ( 'path' ) ;
4
- const symbols = require ( './symbols' )
4
+ const symbols = require ( './symbols' ) ;
5
5
6
6
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
+ }
7
12
8
13
module . exports = {
9
14
include_dir,
15
+ def_paths,
10
16
symbols
11
17
}
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
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' ) ;
5
5
const { symbols } = require ( '..' ) ;
6
6
7
7
function getNodeApiDef ( ) {
@@ -28,11 +28,20 @@ function getJsNativeApiDef() {
28
28
}
29
29
30
30
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' ) ;
32
41
console . log ( `Writing Windows .def file to ${ nodeApiDefPath } ` ) ;
33
42
await writeFile ( nodeApiDefPath , getNodeApiDef ( ) ) ;
34
43
35
- const jsNativeApiDefPath = resolvePath ( __dirname , '../ js_native_api.def' ) ;
44
+ const jsNativeApiDefPath = joinPath ( def , 'js_native_api.def' ) ;
36
45
console . log ( `Writing Windows .def file to ${ jsNativeApiDefPath } ` ) ;
37
46
await writeFile ( jsNativeApiDefPath , getJsNativeApiDef ( ) ) ;
38
47
}
You can’t perform that action at this time.
0 commit comments