diff --git a/webdev/CHANGELOG.md b/webdev/CHANGELOG.md index abc66c2be..fefe68694 100644 --- a/webdev/CHANGELOG.md +++ b/webdev/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1 + +- Exit with an error if unsupported arguments are passed to `build` command. + ## 0.2.0 - Pass the arguments supporting `directory:port` for the `serve` command. diff --git a/webdev/lib/src/command/build_command.dart b/webdev/lib/src/command/build_command.dart index 1d1c64fdd..f2a935c99 100644 --- a/webdev/lib/src/command/build_command.dart +++ b/webdev/lib/src/command/build_command.dart @@ -3,6 +3,9 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; + +import 'package:args/command_runner.dart'; + import 'command_base.dart'; /// Command to execute pub run build_runner build. @@ -16,5 +19,13 @@ class BuildCommand extends CommandBase { final description = 'Run builders to build a package.'; @override - Future run() => runCore('build'); + Future run() { + if (argResults.rest.isNotEmpty) { + throw new UsageException( + 'Arguments were provided that are not supported: ' + '"${argResults.rest.join(' ')}".', + argParser.usage); + } + return runCore('build'); + } } diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index a06406bbd..526c09bf2 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -1,5 +1,5 @@ name: webdev -version: 0.2.0 +version: 0.2.1-dev author: Dart Team homepage: https://github.com/dart-lang/webdev description: >- diff --git a/webdev/test/integration_test.dart b/webdev/test/integration_test.dart index 2ec64c6e0..70f195671 100644 --- a/webdev/test/integration_test.dart +++ b/webdev/test/integration_test.dart @@ -19,6 +19,15 @@ void main() { await process.shouldExit(64); }); + test('passing extra args to build fails with bad usage', () async { + var process = await runWebDev(['build', 'extra', 'args']); + + await expectLater(process.stdout, + emits('Arguments were provided that are not supported: "extra args".')); + + await process.shouldExit(64); + }); + var invalidRanges = >{ 'build_runner': ['0.7.13+1', '0.9.0'], 'build_web_compilers': ['0.3.5', '0.4.0']