Skip to content

Commit

Permalink
Adding quick hack for directory override.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-singer committed Dec 29, 2012
1 parent 1c6b80d commit 0692911
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/dart2js_task.dart
Expand Up @@ -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<String> files}) =>
Dart2JSTask dart2js({String name: "dart2js", List<String> files}) =>
addTask(files, new Dart2JSTask(name));

Path get _dart2jsPath => new Path.fromNative(new Options().executable)
Expand All @@ -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<TaskResult> run(List<InputFile> 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) {
Expand Down

0 comments on commit 0692911

Please sign in to comment.