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

Side by Side Diff: lib/src/utils.dart

Issue 1645343002: Builds / serves multiple HTML files. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Cleanup Created 4 years, 10 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
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 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 library dev_compiler.src.utils; 6 library dev_compiler.src.utils;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 String computeHashFromFile(String filepath) { 308 String computeHashFromFile(String filepath) {
309 var bytes = new File(filepath).readAsBytesSync(); 309 var bytes = new File(filepath).readAsBytesSync();
310 return CryptoUtils.bytesToHex((new MD5()..add(bytes)).close()); 310 return CryptoUtils.bytesToHex((new MD5()..add(bytes)).close());
311 } 311 }
312 312
313 String resourceOutputPath(Uri resourceUri, Uri entryUri, String runtimeDir) { 313 String resourceOutputPath(Uri resourceUri, Uri entryUri, String runtimeDir) {
314 if (resourceUri.scheme == 'package') return resourceUri.path; 314 if (resourceUri.scheme == 'package') return resourceUri.path;
315 315
316 if (resourceUri.scheme != 'file') return null; 316 if (resourceUri.scheme != 'file') return null;
317 317
318 var entryDir = path.dirname(entryUri.path); 318 var entryPath = entryUri.path;
319 var entryDir = entryPath.endsWith('.dart') || entryPath.endsWith('.html')
Jennifer Messerly 2016/01/29 16:49:49 A comment might be nice here, not sure I follow wh
vsm 2016/01/29 18:13:51 Done.
320 ? path.dirname(entryPath)
321 : entryPath;
319 var filepath = path.normalize(path.join(entryDir, resourceUri.path)); 322 var filepath = path.normalize(path.join(entryDir, resourceUri.path));
320 if (path.isWithin(runtimeDir, filepath)) { 323 if (path.isWithin(runtimeDir, filepath)) {
321 filepath = path.relative(filepath, from: runtimeDir); 324 filepath = path.relative(filepath, from: runtimeDir);
322 return path.join('dev_compiler', 'runtime', filepath); 325 return path.join('dev_compiler', 'runtime', filepath);
323 } 326 }
324 327
325 return path.relative(resourceUri.path, from: entryDir); 328 return path.relative(resourceUri.path, from: entryDir);
326 } 329 }
327 330
328 /// Given an annotated [node] and a [test] function, returns the first matching 331 /// Given an annotated [node] and a [test] function, returns the first matching
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (reached.add(e)) { 469 if (reached.add(e)) {
467 var destinations = _adjacencyList[e]; 470 var destinations = _adjacencyList[e];
468 if (destinations != null) destinations.forEach(visit); 471 if (destinations != null) destinations.forEach(visit);
469 } 472 }
470 } 473 }
471 roots.forEach(visit); 474 roots.forEach(visit);
472 475
473 return reached; 476 return reached;
474 } 477 }
475 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698