| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 @JS() | 6 @JS() |
| 7 library dev_compiler.web.main; | 7 library dev_compiler.web.main; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 /// Runs a single compile command, and returns an exit code. | 24 /// Runs a single compile command, and returns an exit code. |
| 25 Future<int> _runCommand(List<String> args, | 25 Future<int> _runCommand(List<String> args, |
| 26 {MessageHandler messageHandler}) async { | 26 {MessageHandler messageHandler}) async { |
| 27 try { | 27 try { |
| 28 // TODO: Remove CommandRunner and args if possible. May run into issues | 28 // TODO: Remove CommandRunner and args if possible. May run into issues |
| 29 // with ArgResults or ArgParsers. | 29 // with ArgResults or ArgParsers. |
| 30 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); | 30 var runner = new CommandRunner('dartdevc', 'Dart Development Compiler'); |
| 31 runner.addCommand(new WebCompileCommand(messageHandler: messageHandler)); | 31 runner.addCommand(new WebCompileCommand(messageHandler: messageHandler)); |
| 32 setUpCompilerInBrowser = allowInterop(await runner.run(args)); | 32 setUpCompilerInBrowser = allowInterop((await runner.run(args)) as Function); |
| 33 } catch (e, s) { | 33 } catch (e, s) { |
| 34 return _handleError(e, s, args, messageHandler: messageHandler); | 34 return _handleError(e, s, args, messageHandler: messageHandler); |
| 35 } | 35 } |
| 36 return 1; | 36 return 1; |
| 37 } | 37 } |
| 38 | 38 |
| 39 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls | 39 /// Handles [error] in a uniform fashion. Returns the proper exit code and calls |
| 40 /// [messageHandler] with messages. | 40 /// [messageHandler] with messages. |
| 41 int _handleError(dynamic error, dynamic stackTrace, List<String> args, | 41 int _handleError(dynamic error, dynamic stackTrace, List<String> args, |
| 42 {MessageHandler messageHandler}) { | 42 {MessageHandler messageHandler}) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 69 messageHandler(""); | 69 messageHandler(""); |
| 70 messageHandler(" dartdevc arguments: " + args.join(' ')); | 70 messageHandler(" dartdevc arguments: " + args.join(' ')); |
| 71 messageHandler(""); | 71 messageHandler(""); |
| 72 messageHandler("```"); | 72 messageHandler("```"); |
| 73 messageHandler(error); | 73 messageHandler(error); |
| 74 messageHandler(stackTrace); | 74 messageHandler(stackTrace); |
| 75 messageHandler("```"); | 75 messageHandler("```"); |
| 76 return 70; | 76 return 70; |
| 77 } | 77 } |
| 78 } | 78 } |
| OLD | NEW |