| OLD | NEW |
| 1 library pub.command.serve; | 1 library pub.command.serve; |
| 2 import 'dart:async'; | 2 import 'dart:async'; |
| 3 import 'dart:math' as math; | 3 import 'dart:math' as math; |
| 4 import 'package:barback/barback.dart'; | 4 import 'package:barback/barback.dart'; |
| 5 import '../barback/asset_environment.dart'; | 5 import '../barback/asset_environment.dart'; |
| 6 import '../barback/pub_package_provider.dart'; | 6 import '../barback/pub_package_provider.dart'; |
| 7 import '../log.dart' as log; | 7 import '../log.dart' as log; |
| 8 import '../utils.dart'; | 8 import '../utils.dart'; |
| 9 import 'barback.dart'; | 9 import 'barback.dart'; |
| 10 final _arrow = getSpecial('\u2192', '=>'); | 10 final _arrow = getSpecial('\u2192', '=>'); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 entrypoint, | 60 entrypoint, |
| 61 mode, | 61 mode, |
| 62 watcherType: watcherType, | 62 watcherType: watcherType, |
| 63 hostname: hostname, | 63 hostname: hostname, |
| 64 basePort: port, | 64 basePort: port, |
| 65 useDart2JS: useDart2JS).then((x2) { | 65 useDart2JS: useDart2JS).then((x2) { |
| 66 try { | 66 try { |
| 67 var environment = x2; | 67 var environment = x2; |
| 68 var directoryLength = | 68 var directoryLength = |
| 69 sourceDirectories.map(((dir) => dir.length)).reduce(math.max
); | 69 sourceDirectories.map(((dir) => dir.length)).reduce(math.max
); |
| 70 environment.startAdminServer(adminPort).then((x3) { | 70 join2() { |
| 71 try { | 71 join3() { |
| 72 var server = x3; | 72 environment.pauseUpdates(); |
| 73 server.results.listen(((_) { | 73 var it0 = sourceDirectories.iterator; |
| 74 assert(false); | 74 break0(x6) { |
| 75 }), onError: _fatalError); | 75 environment.barback.errors.listen(((error) { |
| 76 join2() { | 76 log.error(log.red("Build error:\n$error")); |
| 77 environment.pauseUpdates(); | 77 })); |
| 78 var it0 = sourceDirectories.iterator; | 78 environment.barback.results.listen(((result) { |
| 79 break0(x7) { | 79 if (result.succeeded) { |
| 80 environment.barback.errors.listen(((error) { | 80 log.message( |
| 81 log.error(log.red("Build error:\n$error")); | 81 "Build completed ${log.green('successfully')}"); |
| 82 })); | 82 } else { |
| 83 environment.barback.results.listen(((result) { | 83 log.message( |
| 84 if (result.succeeded) { | 84 "Build completed with " "${log.red(result.errors.l
ength)} errors."); |
| 85 log.message( | 85 } |
| 86 "Build completed ${log.green('successfully')}"); | 86 }), onError: _fatalError); |
| 87 } else { | 87 environment.resumeUpdates(); |
| 88 log.message( | 88 _completer.future.then((x3) { |
| 89 "Build completed with " "${log.red(result.errors
.length)} errors."); | 89 try { |
| 90 } | 90 x3; |
| 91 }), onError: _fatalError); | 91 completer0.complete(null); |
| 92 environment.resumeUpdates(); | 92 } catch (e1) { |
| 93 _completer.future.then((x4) { | 93 completer0.completeError(e1); |
| 94 try { | 94 } |
| 95 x4; | 95 }, onError: (e2) { |
| 96 completer0.complete(null); | 96 completer0.completeError(e2); |
| 97 } catch (e2) { | 97 }); |
| 98 completer0.completeError(e2); | 98 } |
| 99 } | 99 continue0(x7) { |
| 100 }, onError: (e3) { | 100 if (it0.moveNext()) { |
| 101 completer0.completeError(e3); | 101 Future.wait([]).then((x5) { |
| 102 var directory = it0.current; |
| 103 _startServer( |
| 104 environment, |
| 105 directory, |
| 106 directoryLength).then((x4) { |
| 107 try { |
| 108 x4; |
| 109 continue0(null); |
| 110 } catch (e3) { |
| 111 completer0.completeError(e3); |
| 112 } |
| 113 }, onError: (e4) { |
| 114 completer0.completeError(e4); |
| 115 }); |
| 102 }); | 116 }); |
| 117 } else { |
| 118 break0(null); |
| 103 } | 119 } |
| 104 continue0(x8) { | |
| 105 if (it0.moveNext()) { | |
| 106 Future.wait([]).then((x6) { | |
| 107 var directory = it0.current; | |
| 108 _startServer( | |
| 109 environment, | |
| 110 directory, | |
| 111 directoryLength).then((x5) { | |
| 112 try { | |
| 113 x5; | |
| 114 continue0(null); | |
| 115 } catch (e4) { | |
| 116 completer0.completeError(e4); | |
| 117 } | |
| 118 }, onError: (e5) { | |
| 119 completer0.completeError(e5); | |
| 120 }); | |
| 121 }); | |
| 122 } else { | |
| 123 break0(null); | |
| 124 } | |
| 125 } | |
| 126 continue0(null); | |
| 127 } | 120 } |
| 128 if (logAdminUrl) { | 121 continue0(null); |
| 129 log.message( | 122 } |
| 130 "Running admin server on " "${log.bold('http://${hostn
ame}:${server.port}')}"); | 123 if (logAdminUrl) { |
| 124 log.message( |
| 125 "Running admin server on " "${log.bold('http://${hostnam
e}:${server.port}')}"); |
| 126 join3(); |
| 127 } else { |
| 128 join3(); |
| 129 } |
| 130 } |
| 131 if (adminPort != null) { |
| 132 environment.startAdminServer(adminPort).then((x8) { |
| 133 try { |
| 134 var server = x8; |
| 135 server.results.listen(((_) { |
| 136 assert(false); |
| 137 }), onError: _fatalError); |
| 131 join2(); | 138 join2(); |
| 132 } else { | 139 } catch (e5) { |
| 133 join2(); | 140 completer0.completeError(e5); |
| 134 } | 141 } |
| 135 } catch (e1) { | 142 }, onError: (e6) { |
| 136 completer0.completeError(e1); | 143 completer0.completeError(e6); |
| 137 } | 144 }); |
| 138 }, onError: (e6) { | 145 } else { |
| 139 completer0.completeError(e6); | 146 join2(); |
| 140 }); | 147 } |
| 141 } catch (e0) { | 148 } catch (e0) { |
| 142 completer0.completeError(e0); | 149 completer0.completeError(e0); |
| 143 } | 150 } |
| 144 }, onError: (e7) { | 151 }, onError: (e7) { |
| 145 completer0.completeError(e7); | 152 completer0.completeError(e7); |
| 146 }); | 153 }); |
| 147 } | 154 } |
| 148 if (commandOptions['force-poll']) { | 155 if (commandOptions['force-poll']) { |
| 149 join1(WatcherType.POLLING); | 156 join1(WatcherType.POLLING); |
| 150 } else { | 157 } else { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 completer0.completeError(e2); | 219 completer0.completeError(e2); |
| 213 } | 220 } |
| 214 }); | 221 }); |
| 215 return completer0.future; | 222 return completer0.future; |
| 216 } | 223 } |
| 217 void _fatalError(error, [stackTrace]) { | 224 void _fatalError(error, [stackTrace]) { |
| 218 if (_completer.isCompleted) return; | 225 if (_completer.isCompleted) return; |
| 219 _completer.completeError(error, stackTrace); | 226 _completer.completeError(error, stackTrace); |
| 220 } | 227 } |
| 221 } | 228 } |
| OLD | NEW |