| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.cached_package; | 5 library pub.cached_package; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
| 8 import 'package:yaml/yaml.dart'; | 8 import 'package:yaml/yaml.dart'; |
| 9 | 9 |
| 10 import 'barback/transformer_config.dart'; | 10 import 'barback/transformer_config.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 String relative(String path) { | 43 String relative(String path) { |
| 44 if (p.isWithin(path, _cacheDir)) return p.relative(path, from: _cacheDir); | 44 if (p.isWithin(path, _cacheDir)) return p.relative(path, from: _cacheDir); |
| 45 return super.relative(path); | 45 return super.relative(path); |
| 46 } | 46 } |
| 47 | 47 |
| 48 /// This will include the cached, transformed versions of files if [beneath] | 48 /// This will include the cached, transformed versions of files if [beneath] |
| 49 /// is within a cached directory, but not otherwise. | 49 /// is within a cached directory, but not otherwise. |
| 50 List<String> listFiles({String beneath, recursive: true}) { | 50 List<String> listFiles({String beneath, recursive: true, |
| 51 if (beneath == null) return super.listFiles(recursive: recursive); | 51 bool useGitIgnore: false}) { |
| 52 if (beneath == null) { |
| 53 return super.listFiles(recursive: recursive, useGitIgnore: useGitIgnore); |
| 54 } |
| 52 | 55 |
| 53 if (_pathInCache(beneath)) return listDir(p.join(_cacheDir, beneath)); | 56 if (_pathInCache(beneath)) return listDir(p.join(_cacheDir, beneath)); |
| 54 return super.listFiles(beneath: beneath, recursive: recursive); | 57 return super.listFiles(beneath: beneath, recursive: recursive, |
| 58 useGitIgnore: useGitIgnore); |
| 55 } | 59 } |
| 56 | 60 |
| 57 /// Returns whether [relativePath], a path relative to the package's root, | 61 /// Returns whether [relativePath], a path relative to the package's root, |
| 58 /// is in a cached directory. | 62 /// is in a cached directory. |
| 59 bool _pathInCache(String relativePath) => p.isWithin('lib', relativePath); | 63 bool _pathInCache(String relativePath) => p.isWithin('lib', relativePath); |
| 60 } | 64 } |
| 61 | 65 |
| 62 /// A pubspec wrapper that reports no transformers. | 66 /// A pubspec wrapper that reports no transformers. |
| 63 class _CachedPubspec implements Pubspec { | 67 class _CachedPubspec implements Pubspec { |
| 64 final Pubspec _inner; | 68 final Pubspec _inner; |
| 65 | 69 |
| 66 YamlMap get fields => _inner.fields; | 70 YamlMap get fields => _inner.fields; |
| 67 String get name => _inner.name; | 71 String get name => _inner.name; |
| 68 Version get version => _inner.version; | 72 Version get version => _inner.version; |
| 69 List<PackageDep> get dependencies => _inner.dependencies; | 73 List<PackageDep> get dependencies => _inner.dependencies; |
| 70 List<PackageDep> get devDependencies => _inner.devDependencies; | 74 List<PackageDep> get devDependencies => _inner.devDependencies; |
| 71 List<PackageDep> get dependencyOverrides => _inner.dependencyOverrides; | 75 List<PackageDep> get dependencyOverrides => _inner.dependencyOverrides; |
| 72 PubspecEnvironment get environment => _inner.environment; | 76 PubspecEnvironment get environment => _inner.environment; |
| 73 String get publishTo => _inner.publishTo; | 77 String get publishTo => _inner.publishTo; |
| 74 Map<String, String> get executables => _inner.executables; | 78 Map<String, String> get executables => _inner.executables; |
| 75 bool get isPrivate => _inner.isPrivate; | 79 bool get isPrivate => _inner.isPrivate; |
| 76 bool get isEmpty => _inner.isEmpty; | 80 bool get isEmpty => _inner.isEmpty; |
| 77 List<PubspecException> get allErrors => _inner.allErrors; | 81 List<PubspecException> get allErrors => _inner.allErrors; |
| 78 | 82 |
| 79 List<Set<TransformerConfig>> get transformers => const []; | 83 List<Set<TransformerConfig>> get transformers => const []; |
| 80 | 84 |
| 81 _CachedPubspec(this._inner); | 85 _CachedPubspec(this._inner); |
| 82 } | 86 } |
| OLD | NEW |