Skip to content

Commit af37d19

Browse files
[web-generator] Added support for multi-file input for JS Generator (#470)
Added support for multi-file input in the main entrypoint (i.e `bin/gen_interop_bindings.dart`) of the web_generator package.
1 parent 25a0b5b commit af37d19

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

web_generator/bin/gen_interop_bindings.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,17 @@ $_usage''');
5858
await compileDartMain();
5959
}
6060

61-
// TODO(nikeokoronkwo): Multi-file input
62-
final inputFile = argResult.rest.firstOrNull;
63-
final outputFile = argResult['output'] as String? ??
64-
p.join(p.current, inputFile?.replaceAll('.d.ts', '.dart'));
61+
final inputFiles = argResult.rest;
62+
if (inputFiles.isEmpty) {
63+
print('Pass an input file to get started');
64+
print(_usage);
65+
exit(1);
66+
}
67+
final specifiedOutput = argResult['output'] as String?;
68+
final outputFile = specifiedOutput ??
69+
(inputFiles.length > 1
70+
? p.join(p.current, inputFiles.first.replaceAll('.d.ts', '.dart'))
71+
: p.join(p.current, inputFiles.single.replaceAll('.d.ts', '.dart')));
6572
final defaultWebGenConfigPath = p.join(p.current, 'webgen.yaml');
6673
final configFile = argResult['config'] as String? ??
6774
(File(defaultWebGenConfigPath).existsSync()
@@ -83,7 +90,8 @@ $_usage''');
8390
'main.mjs',
8491
'--declaration',
8592
if (argResult.rest.isNotEmpty) ...[
86-
'--input=${p.relative(inputFile!, from: bindingsGeneratorPath)}',
93+
...inputFiles.map(
94+
(i) => '--input=${p.relative(i, from: bindingsGeneratorPath)}'),
8795
'--output=$relativeOutputPath',
8896
],
8997
if (tsConfigRelativePath case final tsConfig?) '--ts-config=$tsConfig',

0 commit comments

Comments
 (0)