| 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 library polymer_interop.src.build.replace_polymer_js.dart; | 4 library polymer_interop.src.build.replace_polymer_js.dart; |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:barback/barback.dart'; | 7 import 'package:barback/barback.dart'; |
| 8 | 8 |
| 9 /// Replaces `polymer.min.js` with `polymer.js` in development mode. | 9 /// Replaces `polymer.min.js` with `polymer.js` in development mode. |
| 10 class ReplacePolymerJsTransformer extends Transformer { | 10 class ReplacePolymerJsTransformer extends Transformer { |
| 11 BarbackSettings settings; | 11 BarbackSettings settings; |
| 12 | 12 |
| 13 ReplacePolymerJsTransformer.asPlugin(this.settings); | 13 ReplacePolymerJsTransformer.asPlugin(this.settings); |
| 14 | 14 |
| 15 bool isPrimary(AssetId id) { | 15 bool isPrimary(AssetId id) { |
| 16 if (settings.mode == BarbackMode.RELEASE) return false; | 16 if (settings.mode == BarbackMode.RELEASE) return false; |
| 17 return id.path == 'lib/src/js/polymer.html'; | 17 return id.path == 'lib/src/js/polymer.html'; |
| 18 } | 18 } |
| 19 | 19 |
| 20 Future apply(Transform transform) async { | 20 Future apply(Transform transform) async { |
| 21 var contents = await transform.primaryInput.readAsString(); | 21 var contents = await transform.primaryInput.readAsString(); |
| 22 contents = contents.replaceFirst('polymer.min.js', 'polymer.js'); | 22 contents = contents.replaceFirst('polymer.min.js', 'polymer.js'); |
| 23 transform | 23 transform |
| 24 .addOutput(new Asset.fromString(transform.primaryInput.id, contents)); | 24 .addOutput(new Asset.fromString(transform.primaryInput.id, contents)); |
| 25 } | 25 } |
| 26 } | 26 } |
| OLD | NEW |