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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart

Issue 203673003: Allow [path.fromUri] to take a string as well as a URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 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 | Annotate | Revision Log
OLDNEW
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.pub_package_provider; 5 library pub.pub_package_provider;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
11 11
12 import '../package_graph.dart'; 12 import '../package_graph.dart';
13 import '../io.dart'; 13 import '../io.dart';
14 14
15 /// An implementation of barback's [PackageProvider] interface so that barback 15 /// An implementation of barback's [PackageProvider] interface so that barback
16 /// can find assets within pub packages. 16 /// can find assets within pub packages.
17 class PubPackageProvider implements PackageProvider { 17 class PubPackageProvider implements PackageProvider {
18 final PackageGraph _graph; 18 final PackageGraph _graph;
19 final List<String> packages; 19 final List<String> packages;
20 20
21 PubPackageProvider(PackageGraph graph) 21 PubPackageProvider(PackageGraph graph)
22 : _graph = graph, 22 : _graph = graph,
23 packages = new List.from(graph.packages.keys)..add(r"$pub"); 23 packages = new List.from(graph.packages.keys)..add(r"$pub");
24 24
25 Future<Asset> getAsset(AssetId id) { 25 Future<Asset> getAsset(AssetId id) {
26 if (id.package != r'$pub') { 26 if (id.package != r'$pub') {
27 var nativePath = path.joinAll(path.url.split(id.path)); 27 var nativePath = path.fromUri(id.path);
28 var file = path.join(_graph.packages[id.package].dir, nativePath); 28 var file = path.join(_graph.packages[id.package].dir, nativePath);
29 return new Future.value(new Asset.fromPath(id, file)); 29 return new Future.value(new Asset.fromPath(id, file));
30 } 30 }
31 31
32 // "$pub" is a psuedo-package that allows pub's transformer-loading 32 // "$pub" is a psuedo-package that allows pub's transformer-loading
33 // infrastructure to share code with pub proper. 33 // infrastructure to share code with pub proper.
34 var components = path.url.split(id.path); 34 var components = path.url.split(id.path);
35 assert(components.isNotEmpty); 35 assert(components.isNotEmpty);
36 assert(components.first == 'lib'); 36 assert(components.first == 'lib');
37 components[0] = 'dart'; 37 components[0] = 'dart';
38 var file = assetPath(path.joinAll(components)); 38 var file = assetPath(path.joinAll(components));
39 return new Future.value(new Asset.fromPath(id, file)); 39 return new Future.value(new Asset.fromPath(id, file));
40 } 40 }
41 } 41 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/build_environment.dart ('k') | sdk/lib/_internal/pub/lib/src/command/build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698