File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Expand file tree Collapse file tree 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`.
5151This property is a string that represents the include path for the Node-API
5252headers.
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
5662This property is an object that represents the symbols exported by Node-API
Original file line number Diff line number Diff line change 11'use strict'
22
33const path = require ( 'path' ) ;
4- const symbols = require ( './symbols' )
4+ const symbols = require ( './symbols' ) ;
55
66const 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
813module . exports = {
914 include_dir,
15+ def_paths,
1016 symbols
1117}
Original file line number Diff line number Diff line change 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' ) ;
55const { symbols } = require ( '..' ) ;
66
77function getNodeApiDef ( ) {
@@ -28,11 +28,20 @@ function getJsNativeApiDef() {
2828}
2929
3030async 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}
You can’t perform that action at this time.
0 commit comments