Index: pkg/observe/lib/transformer.dart |
diff --git a/pkg/observe/lib/transform.dart b/pkg/observe/lib/transformer.dart |
similarity index 94% |
copy from pkg/observe/lib/transform.dart |
copy to pkg/observe/lib/transformer.dart |
index 5e261c02b49b641fe30f36867373bd9a9ca3a9c5..3e6526baea64f02f02eb1d75284e188f4499d673 100644 |
--- a/pkg/observe/lib/transform.dart |
+++ b/pkg/observe/lib/transformer.dart |
@@ -6,7 +6,7 @@ |
* Code transform for @observable. The core transformation is relatively |
* straightforward, and essentially like an editor refactoring. |
*/ |
-library observe.transform; |
+library observe.transformer; |
import 'dart:async'; |
@@ -28,8 +28,33 @@ import 'package:source_maps/span.dart' show SourceFile; |
*/ |
class ObservableTransformer extends Transformer { |
+ final List<String> _files; |
+ ObservableTransformer(); |
+ ObservableTransformer.asPlugin(BarbackSettings settings) |
+ : _files = _readFiles(settings.configuration['files']); |
+ |
+ static List<String> _readFiles(value) { |
+ if (value == null) return null; |
+ var files = []; |
+ bool error; |
+ if (value is List) { |
+ files = value; |
+ error = value.any((e) => e is! String); |
+ } else if (value is String) { |
+ files = [value]; |
+ error = false; |
+ } else { |
+ error = true; |
+ } |
+ if (error) print('Invalid value for "files" in the observe transformer.'); |
+ return files; |
+ } |
+ |
Future<bool> isPrimary(Asset input) { |
- if (input.id.extension != '.dart') return new Future.value(false); |
+ if (input.id.extension != '.dart' || |
+ (_files != null && !_files.contains(input.id.path))) { |
+ return new Future.value(false); |
+ } |
// Note: technically we should parse the file to find accurately the |
// observable annotation, but that seems expensive. It would require almost |
// as much work as applying the transform. We rather have some false |