| OLD | NEW |
| 1 import 'dart:async'; | 1 import 'dart:async'; |
| 2 import 'dart:io'; | 2 import 'dart:io'; |
| 3 import 'package:path/path.dart' as path; | 3 import 'package:path/path.dart' as path; |
| 4 | 4 |
| 5 Future launchDart2Js(args, | 5 List<String> dart2JsCommand(List<String> args) { |
| 6 {bool noStdoutEncoding: false}) { | |
| 7 String basePath = path.fromUri(Platform.script); | 6 String basePath = path.fromUri(Platform.script); |
| 8 while (path.basename(basePath) != 'sdk') { | 7 while (path.basename(basePath) != 'sdk') { |
| 9 basePath = path.dirname(basePath); | 8 basePath = path.dirname(basePath); |
| 10 } | 9 } |
| 11 String dart2jsPath = path.normalize( | 10 String dart2jsPath = |
| 12 path.join(basePath, 'pkg/compiler/lib/src/dart2js.dart')); | 11 path.normalize(path.join(basePath, 'pkg/compiler/lib/src/dart2js.dart')); |
| 13 List allArgs = []; | 12 List command = <String>[]; |
| 14 if (Platform.packageRoot != null) { | 13 if (Platform.packageRoot != null) { |
| 15 allArgs.add('--package-root=${Platform.packageRoot}'); | 14 command.add('--package-root=${Platform.packageRoot}'); |
| 16 } else if (Platform.packageConfig != null) { | 15 } else if (Platform.packageConfig != null) { |
| 17 allArgs.add('--packages=${Platform.packageConfig}'); | 16 command.add('--packages=${Platform.packageConfig}'); |
| 18 } | 17 } |
| 19 allArgs.add(dart2jsPath); | 18 command.add(dart2jsPath); |
| 20 allArgs.addAll(args); | 19 command.addAll(args); |
| 20 return command; |
| 21 } |
| 22 |
| 23 Future launchDart2Js(args, {bool noStdoutEncoding: false}) { |
| 21 if (noStdoutEncoding) { | 24 if (noStdoutEncoding) { |
| 22 return Process.run(Platform.executable, allArgs, stdoutEncoding: null); | 25 return Process.run(Platform.executable, dart2JsCommand(args), |
| 26 stdoutEncoding: null); |
| 23 } else { | 27 } else { |
| 24 return Process.run(Platform.executable, allArgs); | 28 return Process.run(Platform.executable, dart2JsCommand(args)); |
| 25 } | 29 } |
| 26 } | 30 } |
| 27 | |
| OLD | NEW |