| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:polymer/builder.dart'; | 5 import 'package:polymer/builder.dart'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 lint() | 10 lint() |
| 11 .then((_) => deploy()).then(compileToJs); | 11 .then((_) => deploy()).then(compileToJs); |
| 12 } | 12 } |
| 13 | 13 |
| 14 compileToJs(_) { | 14 String findDart2JS() { |
| 15 print("Running dart2js"); | 15 var dartPath = Platform.executable; |
| 16 var dart_path = Platform.executable; | 16 var lastIndex = dartPath.lastIndexOf(Platform.pathSeparator); |
| 17 var dart2js_path = 'dart2js'; | 17 if (lastIndex != -1) { |
| 18 if (dart_path.lastIndexOf(Platform.pathSeparator) != -1) { | 18 var binPath = dartPath.substring(0, lastIndex); |
| 19 var bin_path = dart_path.substring(0, dart_path.lastIndexOf(Platform.pathSep
arator)); | 19 return '$binPath${Platform.pathSeparator}dart2js'; |
| 20 dart2js_path = "$bin_path${Platform.pathSeparator}dart2js"; | |
| 21 } | 20 } |
| 21 return 'dart2js'; |
| 22 } |
| 23 |
| 24 void runDart2JS(String input, String output) { |
| 25 var dart2js_path = findDart2JS(); |
| 22 var result = | 26 var result = |
| 23 Process.runSync(dart2js_path, | 27 Process.runSync(dart2js_path, |
| 24 [ '--minify', '-o', 'out/web/index.html_bootstrap.dart.js', | 28 [ '--minify', '-o', output, input], runInShell: true); |
| 25 'out/web/index.html_bootstrap.dart'], runInShell: true); | |
| 26 print(result.stdout); | 29 print(result.stdout); |
| 27 print(result.stderr); | 30 print(result.stderr); |
| 28 if (result.exitCode != 0) { | 31 if (result.exitCode != 0) { |
| 29 print("Running dart2js failed."); | 32 print("Running dart2js failed."); |
| 30 exit(result.exitCode); | 33 exit(result.exitCode); |
| 31 } | 34 } |
| 35 } |
| 36 |
| 37 compileToJs(_) { |
| 38 print("Running dart2js"); |
| 39 runDart2JS('out/web/index.html_bootstrap.dart', |
| 40 'out/web/index.html_bootstrap.dart.js'); |
| 41 runDart2JS('out/web/index_devtools.html_bootstrap.dart', |
| 42 'out/web/index_devtools.html_bootstrap.dart.js'); |
| 32 print("Done"); | 43 print("Done"); |
| 33 } | 44 } |
| OLD | NEW |