Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: lib/devc.dart

Issue 1001503003: server: create output directory if needed (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 var port = options.port; 260 var port = options.port;
261 _log.fine('Serving $entryPath at http://0.0.0.0:$port/'); 261 _log.fine('Serving $entryPath at http://0.0.0.0:$port/');
262 var compiler = new Compiler(options); 262 var compiler = new Compiler(options);
263 return new CompilerServer._(compiler, outDir, port, entryPath); 263 return new CompilerServer._(compiler, outDir, port, entryPath);
264 } 264 }
265 265
266 CompilerServer._(this.compiler, this.outDir, this.port, this._entryPath); 266 CompilerServer._(this.compiler, this.outDir, this.port, this._entryPath);
267 267
268 Future start() async { 268 Future start() async {
269 // Create output directory if needed. shelf_static will fail otherwise.
270 var out = new Directory(outDir);
271 if (!await out.exists()) await out.create(recursive: true);
272
269 var handler = const shelf.Pipeline() 273 var handler = const shelf.Pipeline()
270 .addMiddleware(rebuildAndCache) 274 .addMiddleware(rebuildAndCache)
271 .addHandler(shelf_static.createStaticHandler(outDir, 275 .addHandler(shelf_static.createStaticHandler(outDir,
272 defaultDocument: _entryPath)); 276 defaultDocument: _entryPath));
273 await shelf.serve(handler, '0.0.0.0', port); 277 await shelf.serve(handler, '0.0.0.0', port);
274 compiler.run(); 278 compiler.run();
275 } 279 }
276 280
277 shelf.Handler rebuildAndCache(shelf.Handler handler) => (request) { 281 shelf.Handler rebuildAndCache(shelf.Handler handler) => (request) {
278 _log.fine('requested $GREEN_COLOR${request.url}$NO_COLOR'); 282 _log.fine('requested $GREEN_COLOR${request.url}$NO_COLOR');
(...skipping 19 matching lines...) Expand all
298 // Note: the cache-control header should be enough, but this doesn't hurt 302 // Note: the cache-control header should be enough, but this doesn't hurt
299 // and can help renew the policy after it expires. 303 // and can help renew the policy after it expires.
300 headers['ETag'] = segments[1]; 304 headers['ETag'] = segments[1];
301 } 305 }
302 return response.change(headers: headers); 306 return response.change(headers: headers);
303 }; 307 };
304 } 308 }
305 309
306 final _log = new Logger('dev_compiler'); 310 final _log = new Logger('dev_compiler');
307 final _earlyErrorResult = new CheckerResults(const [], null, true); 311 final _earlyErrorResult = new CheckerResults(const [], null, true);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698