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

Unified Diff: pkg/polymer/lib/builder.dart

Issue 569393002: no longer require entry points to be specified in the build.dart file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: return null if not found Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/polymer/lib/default_build.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/builder.dart
diff --git a/pkg/polymer/lib/builder.dart b/pkg/polymer/lib/builder.dart
index a2eb80fe467c3650be771424b07168ece67e90f2..3176ed7d4c5f79e6faea92c8225da493cb790912 100644
--- a/pkg/polymer/lib/builder.dart
+++ b/pkg/polymer/lib/builder.dart
@@ -83,6 +83,8 @@ import 'dart:async';
import 'dart:io';
import 'package:args/args.dart';
+import 'package:path/path.dart' as path;
+import 'package:yaml/yaml.dart';
import 'src/build/linter.dart';
import 'src/build/runner.dart';
@@ -116,6 +118,8 @@ Future build({List<String> entryPoints, CommandLineOptions options,
' options to build(). Running as if no options were passed.');
options = parseOptions([]);
}
+ if (entryPoints == null) entryPoints = _parseEntryPointsFromPubspec();
+
return options.forceDeploy
? deploy(entryPoints: entryPoints, options: options,
currentPackage: currentPackage, packageDirs: packageDirs)
@@ -145,8 +149,10 @@ Future lint({List<String> entryPoints, CommandLineOptions options,
options = parseOptions([]);
}
if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
+ if (entryPoints == null) entryPoints = _parseEntryPointsFromPubspec();
var linterOptions = new TransformOptions(entryPoints: entryPoints);
var linter = new Linter(linterOptions);
+
return runBarback(new BarbackOptions([[linter]], null,
currentPackage: currentPackage, packageDirs: packageDirs,
machineFormat: options.machineFormat));
@@ -177,6 +183,7 @@ Future deploy({List<String> entryPoints, CommandLineOptions options,
options = parseOptions([]);
}
if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
+ if (entryPoints == null) entryPoints = _parseEntryPointsFromPubspec();
var transformOptions = new TransformOptions(
entryPoints: entryPoints,
@@ -318,3 +325,31 @@ CommandLineOptions parseOptions([List<String> args]) {
res['full'], res['machine'], res['deploy'], res['out'], res['js'],
res['csp'], !res['debug']);
}
+
+List<String> _parseEntryPointsFromPubspec() {
+ var entryPoints = [];
+ var pubspec = new File(path.join(
+ path.dirname(Platform.script.path), 'pubspec.yaml'));
+ if (!pubspec.existsSync()) {
+ print('error: pubspec.yaml file not found.');
+ return null;
+ }
+ var transformers = loadYaml(pubspec.readAsStringSync())['transformers'];
+ if (transformers == null) return null;
+ if (transformers is! List) {
+ print('Unexpected value for transformers, expected a List.');
+ return null;
+ }
+
+ transformers.forEach((t) {
+ if (t is! Map) return;
+ var polymer = t['polymer'];
+ if (polymer == null || polymer is! Map) return;
+
+ var parsedEntryPoints = readEntrypoints(polymer['entry_points']);
+ if (parsedEntryPoints == null) return;
+
+ entryPoints.addAll(parsedEntryPoints);
+ });
+ return entryPoints.isEmpty ? null : entryPoints;
+}
« no previous file with comments | « no previous file | pkg/polymer/lib/default_build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698