diff --git a/lib/dart2js_task.dart b/lib/dart2js_task.dart index e57f91d..b0d5e11 100644 --- a/lib/dart2js_task.dart +++ b/lib/dart2js_task.dart @@ -14,7 +14,7 @@ import 'package:logging/logging.dart'; Logger get _logger => new Logger('dart2js'); /** Adds a dart2js task to the build configuration. */ -Dart2JSTask dart2js({String name: "dart2js", List files}) => +Dart2JSTask dart2js({String name: "dart2js", List files}) => addTask(files, new Dart2JSTask(name)); Path get _dart2jsPath => new Path.fromNative(new Options().executable) @@ -23,21 +23,28 @@ Path get _dart2jsPath => new Path.fromNative(new Options().executable) /** Runs dart2js on the input files. */ class Dart2JSTask extends Task { + Path outDirectory; + Dart2JSTask(String name) : super(name); - + Dart2JSTask.withOutDir(String name, this.outDirectory) : super(name); + Future run(List files, Path outDir, Path genDir) { + if (outDirectory != null) { + outDir = outDirectory; + } + _logger.info("dart2js task starting. files: $files"); var futureGroup = new FutureGroup(); for (var file in files) { var outPath = outDir.append('${file.path}.js'); var outFileDir = outPath.directoryPath; - + new Directory.fromPath(outFileDir).createSync(recursive: true); - + var options = new ProcessOptions() ..workingDirectory = new Directory.current().path; var args = ['--out=$outPath', '--verbose', file.inputPath.toNativePath()]; - + _logger.fine("running $_dart2jsPath args: $args"); futureGroup.add(Process.run(_dart2jsPath.toNativePath(), args, options) ..transform((ProcessResult result) {