Chromium Code Reviews| Index: pkg/barback/lib/src/transformer.dart |
| diff --git a/pkg/barback/lib/src/transformer.dart b/pkg/barback/lib/src/transformer.dart |
| index 6eed17af60f3b4695c0355556ede0e64ea2a8236..669478b1a6ed369ed0feef12e6fdc68e83bdfcbf 100644 |
| --- a/pkg/barback/lib/src/transformer.dart |
| +++ b/pkg/barback/lib/src/transformer.dart |
| @@ -8,6 +8,7 @@ import 'dart:async'; |
| import 'asset.dart'; |
| import 'transform.dart'; |
| +import 'utils.dart'; |
| /// A [Transformer] represents a processor that takes in one or more input |
| /// assets and uses them to generate one or more output assets. |
| @@ -23,11 +24,26 @@ abstract class Transformer { |
| /// (with leading `.`) that are allowed for the primary inputs to this |
|
Bob Nystrom
2014/03/12 23:25:28
Remove the "(with leading `.`)" part.
nweiz
2014/03/12 23:30:48
Done.
|
| /// transformer. |
| /// |
| + /// Each extension must begin with a leading `.`. |
| + /// |
| /// If you don't override [isPrimary] yourself, it defaults to allowing any |
| /// asset whose extension matches one of the ones returned by this. If you |
| /// don't override [isPrimary] *or* this, it allows all files. |
| String get allowedExtensions => null; |
| + Transformer() { |
| + if (allowedExtensions == null) return; |
| + |
| + var invalidExtensions = allowedExtensions.split(" ") |
| + .where((extension) => !extension.startsWith(".")) |
| + .map((extension) => '"$extension"'); |
| + if (invalidExtensions.isEmpty) return; |
| + |
| + throw new FormatException('Each extension in $this.allowedExtensions ' |
| + 'must begin with a ".", but ${toSentence(invalidExtensions)} ' |
| + '${pluralize("doesn't", invalidExtensions.length, plural: "don't")}.'); |
| + } |
| + |
| /// Returns `true` if [input] can be a primary input for this transformer. |
| /// |
| /// While a transformer can read from multiple input files, one must be the |
| @@ -49,7 +65,7 @@ abstract class Transformer { |
| if (allowedExtensions == null) return new Future.value(true); |
| for (var extension in allowedExtensions.split(" ")) { |
| - if (input.id.extension == extension) return new Future.value(true); |
| + if (input.id.path.endsWith(extension)) return new Future.value(true); |
| } |
| return new Future.value(false); |