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 library pub.command.serve; | 5 library pub.command.serve; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
| 9 import 'package:barback/barback.dart'; |
| 10 |
9 import '../barback/dart_forwarding_transformer.dart'; | 11 import '../barback/dart_forwarding_transformer.dart'; |
10 import '../barback/dart2js_transformer.dart'; | 12 import '../barback/dart2js_transformer.dart'; |
11 import '../barback/pub_package_provider.dart'; | 13 import '../barback/pub_package_provider.dart'; |
12 import '../barback.dart' as barback; | 14 import '../barback.dart' as barback; |
13 import '../command.dart'; | 15 import '../command.dart'; |
14 import '../entrypoint.dart'; | 16 import '../entrypoint.dart'; |
15 import '../exit_codes.dart' as exit_codes; | 17 import '../exit_codes.dart' as exit_codes; |
16 import '../io.dart'; | 18 import '../io.dart'; |
17 import '../log.dart' as log; | 19 import '../log.dart' as log; |
18 import '../utils.dart'; | 20 import '../utils.dart'; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 }).then((graph) { | 70 }).then((graph) { |
69 // TODO(rnystrom): Add support for dart2dart transformer here. | 71 // TODO(rnystrom): Add support for dart2dart transformer here. |
70 var builtInTransformers = null; | 72 var builtInTransformers = null; |
71 if (useDart2JS) { | 73 if (useDart2JS) { |
72 builtInTransformers = [ | 74 builtInTransformers = [ |
73 new Dart2JSTransformer(graph, minify: minify), | 75 new Dart2JSTransformer(graph, minify: minify), |
74 new DartForwardingTransformer() | 76 new DartForwardingTransformer() |
75 ]; | 77 ]; |
76 } | 78 } |
77 | 79 |
78 return barback.createServer(hostname, port, graph, | 80 // TODO(rnystrom): Allow specifying other modes. |
| 81 return barback.createServer(hostname, port, graph, BarbackMode.DEBUG, |
79 builtInTransformers: builtInTransformers); | 82 builtInTransformers: builtInTransformers); |
80 }).then((server) { | 83 }).then((server) { |
81 /// This completer is used to keep pub running (by not completing) and | 84 /// This completer is used to keep pub running (by not completing) and |
82 /// to pipe fatal errors to pub's top-level error-handling machinery. | 85 /// to pipe fatal errors to pub's top-level error-handling machinery. |
83 var completer = new Completer(); | 86 var completer = new Completer(); |
84 | 87 |
85 server.barback.errors.listen((error) { | 88 server.barback.errors.listen((error) { |
86 log.error(log.red("Build error:\n$error")); | 89 log.error(log.red("Build error:\n$error")); |
87 }); | 90 }); |
88 | 91 |
(...skipping 27 matching lines...) Expand all Loading... |
116 if (!completer.isCompleted) completer.completeError(error, stackTrace); | 119 if (!completer.isCompleted) completer.completeError(error, stackTrace); |
117 }); | 120 }); |
118 | 121 |
119 log.message("Serving ${entrypoint.root.name} " | 122 log.message("Serving ${entrypoint.root.name} " |
120 "on http://$hostname:${server.port}"); | 123 "on http://$hostname:${server.port}"); |
121 | 124 |
122 return completer.future; | 125 return completer.future; |
123 }); | 126 }); |
124 } | 127 } |
125 } | 128 } |
OLD | NEW |