Skip to content

Commit 7dc709f

Browse files
committed
Exit with an error if unsupported arguments are passed to build
Fixes #41
1 parent 8696973 commit 7dc709f

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

webdev/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1
2+
3+
- Exit with an error if unsupported arguments are passed to `build` command.
4+
15
## 0.2.0
26

37
- Pass the arguments supporting `directory:port` for the `serve` command.

webdev/lib/src/command/build_command.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'dart:async';
6+
7+
import 'package:args/command_runner.dart';
8+
69
import 'command_base.dart';
710

811
/// Command to execute pub run build_runner build.
@@ -16,5 +19,13 @@ class BuildCommand extends CommandBase {
1619
final description = 'Run builders to build a package.';
1720

1821
@override
19-
Future<int> run() => runCore('build');
22+
Future<int> run() {
23+
if (argResults.rest.isNotEmpty) {
24+
throw new UsageException(
25+
'Arguments were provided that are not supported: '
26+
'"${argResults.rest.join(' ')}".',
27+
argParser.usage);
28+
}
29+
return runCore('build');
30+
}
2031
}

webdev/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: webdev
2-
version: 0.2.0
2+
version: 0.2.1-dev
33
author: Dart Team <[email protected]>
44
homepage: https://github.com/dart-lang/webdev
55
description: >-

webdev/test/integration_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ void main() {
1919
await process.shouldExit(64);
2020
});
2121

22+
test('passing extra args to build fails with bad usage', () async {
23+
var process = await runWebDev(['build', 'extra', 'args']);
24+
25+
await expectLater(process.stdout,
26+
emits('Arguments were provided that are not supported: "extra args".'));
27+
28+
await process.shouldExit(64);
29+
});
30+
2231
var invalidRanges = <String, List<String>>{
2332
'build_runner': ['0.7.13+1', '0.9.0'],
2433
'build_web_compilers': ['0.3.5', '0.4.0']

0 commit comments

Comments
 (0)