Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. | 5 /// Command line tool to run the checker on a Dart program. |
| 6 library dev_compiler.devc; | 6 library dev_compiler.devc; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 | 268 |
| 269 Future start() async { | 269 Future start() async { |
| 270 // Create output directory if needed. shelf_static will fail otherwise. | 270 // Create output directory if needed. shelf_static will fail otherwise. |
| 271 var out = new Directory(outDir); | 271 var out = new Directory(outDir); |
| 272 if (!await out.exists()) await out.create(recursive: true); | 272 if (!await out.exists()) await out.create(recursive: true); |
| 273 | 273 |
| 274 var handler = const shelf.Pipeline() | 274 var handler = const shelf.Pipeline() |
| 275 .addMiddleware(rebuildAndCache) | 275 .addMiddleware(rebuildAndCache) |
| 276 .addHandler(shelf_static.createStaticHandler(outDir, | 276 .addHandler(shelf_static.createStaticHandler(outDir, |
| 277 defaultDocument: _entryPath)); | 277 defaultDocument: _entryPath)); |
| 278 await shelf.serve(handler, '0.0.0.0', port); | 278 await shelf.serve(handler, 'localhost', port); |
|
Siggi Cherem (dart-lang)
2015/03/19 21:15:02
mmm, I used to have this but change it to 0.0.0.0
Jennifer Messerly
2015/03/19 21:18:24
for flag: can it be host name to connect to? That
| |
| 279 compiler.run(); | 279 compiler.run(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 shelf.Handler rebuildAndCache(shelf.Handler handler) => (request) { | 282 shelf.Handler rebuildAndCache(shelf.Handler handler) => (request) { |
| 283 _log.fine('requested $GREEN_COLOR${request.url}$NO_COLOR'); | 283 _log.fine('requested $GREEN_COLOR${request.url}$NO_COLOR'); |
| 284 // Trigger recompile only when requesting the HTML page. | 284 // Trigger recompile only when requesting the HTML page. |
| 285 var segments = request.url.pathSegments; | 285 var segments = request.url.pathSegments; |
| 286 bool isEntryPage = segments.length == 0 || segments[0] == _entryPath; | 286 bool isEntryPage = segments.length == 0 || segments[0] == _entryPath; |
| 287 if (isEntryPage) compiler._runAgain(); | 287 if (isEntryPage) compiler._runAgain(); |
| 288 | 288 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 303 // Note: the cache-control header should be enough, but this doesn't hurt | 303 // Note: the cache-control header should be enough, but this doesn't hurt |
| 304 // and can help renew the policy after it expires. | 304 // and can help renew the policy after it expires. |
| 305 headers['ETag'] = segments[1]; | 305 headers['ETag'] = segments[1]; |
| 306 } | 306 } |
| 307 return response.change(headers: headers); | 307 return response.change(headers: headers); |
| 308 }; | 308 }; |
| 309 } | 309 } |
| 310 | 310 |
| 311 final _log = new Logger('dev_compiler'); | 311 final _log = new Logger('dev_compiler'); |
| 312 final _earlyErrorResult = new CheckerResults(const [], null, true); | 312 final _earlyErrorResult = new CheckerResults(const [], null, true); |
| OLD | NEW |