Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for build_runner build #3

Merged
merged 2 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions webdev/bin/webdev.dart
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);
}
33 changes: 33 additions & 0 deletions webdev/lib/src/command/build_command.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:async';
import 'package:io/io.dart';

import 'package:args/args.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.';

// TODO(nshahan) Remove once we are not just passing all arguments through.
final _anyArgs = new ArgParser(allowTrailingOptions: false);
@override
ArgParser get argParser => _anyArgs;

@override
Future run() async {
// TODO(nshahan) Is there a better way to pipe standard out/in?
// Would like to have consistent colors and spacing with build_runner.
final manager = new ProcessManager();
final executable = 'pub';
final arguments = ['run', 'build_runner', 'build'];
arguments.addAll(argResults.rest);
var spawn = await manager.spawn(executable, arguments);

await spawn.exitCode;
await sharedStdIn.terminate();
}
}
13 changes: 13 additions & 0 deletions webdev/lib/src/webdev_command_runner.dart
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;
}
1 change: 1 addition & 0 deletions webdev/lib/webdev.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/webdev_command_runner.dart';
4 changes: 4 additions & 0 deletions webdev/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ homepage: https://github.com/dart-lang/webdev
environment:
sdk: ">=2.0.0-dev <2.0.0"

dependencies:
args: ^1.2.0
io: ^0.3.1

dev_dependencies:
test: "^0.12.0"