Skip to content

Commit f44cc33

Browse files
authored
allow build_runner args to the build command (#303)
1 parent 73fa54f commit f44cc33

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

webdev/lib/src/command/build_command.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,22 @@ class BuildCommand extends Command<int> {
3434

3535
@override
3636
Future<int> run() async {
37-
if (argResults.rest.isNotEmpty) {
37+
var unsupported =
38+
argResults.rest.where((arg) => !arg.startsWith('-')).toList();
39+
if (unsupported.isNotEmpty) {
3840
throw UsageException(
3941
'Arguments were provided that are not supported: '
40-
'"${argResults.rest.join(' ')}".',
42+
'"${unsupported.join(' ')}".',
4143
argParser.usage);
4244
}
45+
var extraArgs =
46+
argResults.rest.where((arg) => arg.startsWith('-')).toList();
4347

4448
var configuration = Configuration.fromArgs(argResults);
4549
setVerbosity(configuration.verbose);
4650
var pubspecLock = await readPubspecLock(configuration);
47-
final arguments = buildRunnerArgs(pubspecLock, configuration);
51+
final arguments = buildRunnerArgs(pubspecLock, configuration)
52+
..addAll(extraArgs);
4853

4954
try {
5055
logHandler(Level.INFO, 'Connecting to the build daemon...');

webdev/test/e2e_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ void main() {
6262
await process.shouldExit(isNot(0));
6363
});
6464

65+
test('build should allow passing extra arguments to build_runner', () async {
66+
var args = [
67+
'build',
68+
'-o',
69+
'web:${d.sandbox}',
70+
'--',
71+
'--delete-conflicting-outputs'
72+
];
73+
74+
var process = await runWebDev(args, workingDirectory: exampleDirectory);
75+
76+
await checkProcessStdout(process, ['Succeeded']);
77+
await process.shouldExit(0);
78+
});
79+
6580
group('should build with valid configuration', () {
6681
for (var withDDC in [true, false]) {
6782
test(withDDC ? 'DDC' : 'dart2js', () async {

0 commit comments

Comments
 (0)