-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for build_runner build (#3)
Supports a subset of arguments to pass through to the build command.
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:webdev/webdev.dart'; | ||
|
||
Future main(List<String> args) async { | ||
await webdevCommandRunner().run(args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:async'; | ||
import 'package:io/io.dart'; | ||
|
||
import 'package:args/command_runner.dart'; | ||
|
||
/// Command to execute pub run build_runner build. | ||
class BuildCommand extends Command { | ||
@override | ||
final name = 'build'; | ||
|
||
@override | ||
final description = 'Run builders to build a package.'; | ||
|
||
BuildCommand() { | ||
// TODO(nshahan) Expose more args passed to build_runner build. | ||
// build_runner might expose args for use in wrapping scripts like this one. | ||
argParser | ||
..addOption('output', | ||
abbr: 'o', help: 'A directory to write the result of a build to.') | ||
..addFlag('verbose', | ||
abbr: 'v', | ||
defaultsTo: false, | ||
negatable: false, | ||
help: 'Enables verbose logging.'); | ||
} | ||
|
||
@override | ||
Future run() async { | ||
final manager = new ProcessManager(); | ||
final executable = 'pub'; | ||
final arguments = ['run', 'build_runner', 'build', '--assume-tty']; | ||
arguments.addAll(argResults.arguments); | ||
var spawn = await manager.spawn(executable, arguments); | ||
|
||
await spawn.exitCode; | ||
await sharedStdIn.terminate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:args/command_runner.dart'; | ||
|
||
import 'command/build_command.dart'; | ||
|
||
/// All available top level commands. | ||
CommandRunner webdevCommandRunner() { | ||
final commandRunner = | ||
new CommandRunner('webdev', 'A tool to develop Dart web projects.'); | ||
|
||
commandRunner.addCommand(new BuildCommand()); | ||
|
||
return commandRunner; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'src/webdev_command_runner.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters