Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: samples/third_party/dromaeo/lib/transformer.dart

Issue 223553008: Only pass an AssetId to isPrimary and declareOutputs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix script_compactor Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/smoke/pubspec.yaml ('k') | samples/third_party/dromaeo/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library dromaeo.transformer; 1 library dromaeo.transformer;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'package:barback/barback.dart'; 4 import 'package:barback/barback.dart';
5 5
6 /// Transformer used by `pub build` and `pub serve` to rewrite dromaeo html 6 /// Transformer used by `pub build` and `pub serve` to rewrite dromaeo html
7 /// files to run performance tests. 7 /// files to run performance tests.
8 class DromaeoTransformer extends Transformer { 8 class DromaeoTransformer extends Transformer {
9 9
10 final BarbackSettings settings; 10 final BarbackSettings settings;
11 11
12 DromaeoTransformer.asPlugin(this.settings); 12 DromaeoTransformer.asPlugin(this.settings);
13 13
14 /// The index.html file and the tests/dom-*-html.html files are the ones we 14 /// The index.html file and the tests/dom-*-html.html files are the ones we
15 /// apply this transform to. 15 /// apply this transform to.
16 Future<bool> isPrimary(Asset asset) { 16 Future<bool> isPrimary(AssetId id) {
17 var reg = new RegExp('(tests/dom-.+-html\.html\$)|(index\.html\$)'); 17 var reg = new RegExp('(tests/dom-.+-html\.html\$)|(index\.html\$)');
18 return new Future.value(reg.hasMatch(asset.id.path)); 18 return new Future.value(reg.hasMatch(id.path));
19 } 19 }
20 20
21 Future apply(Transform transform) { 21 Future apply(Transform transform) {
22 Asset primaryAsset = transform.primaryInput; 22 Asset primaryAsset = transform.primaryInput;
23 AssetId primaryAssetId = primaryAsset.id; 23 AssetId primaryAssetId = primaryAsset.id;
24 24
25 return primaryAsset.readAsString().then((String fileContents) { 25 return primaryAsset.readAsString().then((String fileContents) {
26 var filename = primaryAssetId.toString(); 26 var filename = primaryAssetId.toString();
27 var outputFileContents = fileContents; 27 var outputFileContents = fileContents;
28 28
(...skipping 22 matching lines...) Expand all
51 /// Given an html file that sources a Dart file, rewrite the html to instead 51 /// Given an html file that sources a Dart file, rewrite the html to instead
52 /// source the compiled JavaScript file. 52 /// source the compiled JavaScript file.
53 String _sourceJsNotDart(String fileContents) { 53 String _sourceJsNotDart(String fileContents) {
54 var dartScript = new RegExp( 54 var dartScript = new RegExp(
55 '<script type="application/dart" src="([\\w-]+)\.dart">'); 55 '<script type="application/dart" src="([\\w-]+)\.dart">');
56 var match = dartScript.firstMatch(fileContents); 56 var match = dartScript.firstMatch(fileContents);
57 return fileContents.replaceAll(dartScript, '<script type="text/javascript"' 57 return fileContents.replaceAll(dartScript, '<script type="text/javascript"'
58 ' src="${match.group(1)+ ".dart.js"}" defer>'); 58 ' src="${match.group(1)+ ".dart.js"}" defer>');
59 } 59 }
60 } 60 }
OLDNEW
« no previous file with comments | « pkg/smoke/pubspec.yaml ('k') | samples/third_party/dromaeo/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698