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 barback.test.transformer.aggregate_many_to_one; | 5 library barback.test.transformer.aggregate_many_to_one; |
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 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
(...skipping 17 matching lines...) Expand all Loading... |
28 AggregateManyToOneTransformer(this.extension, this.output); | 28 AggregateManyToOneTransformer(this.extension, this.output); |
29 | 29 |
30 String doClassifyPrimary(AssetId id) { | 30 String doClassifyPrimary(AssetId id) { |
31 if (id.extension != ".$extension") return null; | 31 if (id.extension != ".$extension") return null; |
32 return path.url.dirname(id.path); | 32 return path.url.dirname(id.path); |
33 } | 33 } |
34 | 34 |
35 Future doApply(AggregateTransform transform) async { | 35 Future doApply(AggregateTransform transform) async { |
36 var assets = await getPrimaryInputs(transform).toList(); | 36 var assets = await getPrimaryInputs(transform).toList(); |
37 assets.sort((asset1, asset2) => asset1.id.path.compareTo(asset2.id.path)); | 37 assets.sort((asset1, asset2) => asset1.id.path.compareTo(asset2.id.path)); |
38 var contents = await Future.wait( | 38 var contents = |
39 assets.map((asset) => asset.readAsString())); | 39 await Future.wait(assets.map((asset) => asset.readAsString())); |
40 var id = new AssetId(transform.package, | 40 var id = |
41 path.url.join(transform.key, output)); | 41 new AssetId(transform.package, path.url.join(transform.key, output)); |
42 transform.addOutput(new Asset.fromString(id, contents.join('\n'))); | 42 transform.addOutput(new Asset.fromString(id, contents.join('\n'))); |
43 } | 43 } |
44 | 44 |
45 String toString() => "aggregate $extension->$output"; | 45 String toString() => "aggregate $extension->$output"; |
46 } | 46 } |
OLD | NEW |