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.excluding_transformer; | 5 library pub.excluding_transformer; |
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 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 /// assets are allowed. | 30 /// assets are allowed. |
31 final Set<String> _includes; | 31 final Set<String> _includes; |
32 | 32 |
33 /// The set of assets which should be excluded. | 33 /// The set of assets which should be excluded. |
34 /// | 34 /// |
35 /// Exclusions are applied after inclusions. | 35 /// Exclusions are applied after inclusions. |
36 final Set<String> _excludes; | 36 final Set<String> _excludes; |
37 | 37 |
38 ExcludingTransformer._(this._inner, this._includes, this._excludes); | 38 ExcludingTransformer._(this._inner, this._includes, this._excludes); |
39 | 39 |
40 Future<bool> isPrimary(AssetId id) { | 40 isPrimary(AssetId id) { |
41 // TODO(rnystrom): Support globs in addition to paths. See #17093. | 41 // TODO(rnystrom): Support globs in addition to paths. See #17093. |
42 if (_includes != null) { | 42 if (_includes != null) { |
43 // If there are any includes, it must match one of them. | 43 // If there are any includes, it must match one of them. |
44 if (!_includes.contains(id.path)) return new Future.value(false); | 44 if (!_includes.contains(id.path)) return false; |
45 } | 45 } |
46 | 46 |
47 // It must not be excluded. | 47 // It must not be excluded. |
48 if (_excludes != null && _excludes.contains(id.path)) { | 48 if (_excludes != null && _excludes.contains(id.path)) { |
49 return new Future.value(false); | 49 return false; |
50 } | 50 } |
51 | 51 |
52 return _inner.isPrimary(id); | 52 return _inner.isPrimary(id); |
53 } | 53 } |
54 | 54 |
55 Future apply(Transform transform) => _inner.apply(transform); | 55 Future apply(Transform transform) => _inner.apply(transform); |
56 | 56 |
57 String toString() => _inner.toString(); | 57 String toString() => _inner.toString(); |
58 } | 58 } |
OLD | NEW |