55 OPTION_HEADER_KEY_REGEX ,
66} from './constants.mjs' ;
77import { join } from 'node:path' ;
8+ import schema from './schema.json' with { type : 'json ' } ;
89
910/**
1011 * This generator generates the `node.config.json` schema.
@@ -27,16 +28,13 @@ export default {
2728 * @throws {Error } If the required files node_options.cc or node_options.h are missing or invalid.
2829 */
2930 async generate ( _ , options ) {
30- let ccFile , hFile ;
31-
3231 // Ensure input files are provided and capture the paths
33- for ( const filePath of options . input ) {
34- if ( filePath . endsWith ( 'node_options.cc' ) ) {
35- ccFile = filePath ;
36- } else if ( filePath . endsWith ( 'node_options.h' ) ) {
37- hFile = filePath ;
38- }
39- }
32+ const ccFile = options . input . find ( filePath =>
33+ filePath . endsWith ( 'node_options.cc' )
34+ ) ;
35+ const hFile = options . input . find ( filePath =>
36+ filePath . endsWith ( 'node_options.h' )
37+ ) ;
4038
4139 // Error handling if either cc or h file is missing
4240 if ( ! ccFile || ! hFile ) {
@@ -46,9 +44,6 @@ export default {
4644 // Read the contents of the cc and h files
4745 const ccContent = await readFile ( ccFile , 'utf-8' ) ;
4846 const hContent = await readFile ( hFile , 'utf-8' ) ;
49- const schema = JSON . parse (
50- await readFile ( new URL ( './schema.json' , import . meta. url ) )
51- ) ;
5247
5348 const { nodeOptions } = schema . properties ;
5449
0 commit comments