| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 5 /** |
| 6 * Definitions used to run the polymer linter and deploy tools without using | 6 * Definitions used to run the polymer linter and deploy tools without using |
| 7 * pub serve or pub deploy. | 7 * pub serve or pub deploy. |
| 8 */ | 8 */ |
| 9 library polymer.src.build.runner; | 9 library polymer.src.build.runner; |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 /** Directory where to generate code, if any. */ | 41 /** Directory where to generate code, if any. */ |
| 42 final String outDir; | 42 final String outDir; |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Whether to print error messages using a json-format that tools, such as the | 45 * Whether to print error messages using a json-format that tools, such as the |
| 46 * Dart Editor, can process. | 46 * Dart Editor, can process. |
| 47 */ | 47 */ |
| 48 final bool machineFormat; | 48 final bool machineFormat; |
| 49 | 49 |
| 50 /** |
| 51 * Whether to follow symlinks when listing directories. By default this is |
| 52 * false because directories have symlinks for the packages directory created |
| 53 * by pub, but it can be turned on for custom uses of this library. |
| 54 */ |
| 55 final bool followLinks; |
| 56 |
| 50 BarbackOptions(this.phases, this.outDir, {currentPackage, packageDirs, | 57 BarbackOptions(this.phases, this.outDir, {currentPackage, packageDirs, |
| 51 this.transformTests: false, this.transformPolymerDependencies: false, | 58 this.transformTests: false, this.transformPolymerDependencies: false, |
| 52 this.machineFormat: false}) | 59 this.machineFormat: false, this.followLinks: false}) |
| 53 : currentPackage = (currentPackage != null | 60 : currentPackage = (currentPackage != null |
| 54 ? currentPackage : readCurrentPackageFromPubspec()), | 61 ? currentPackage : readCurrentPackageFromPubspec()), |
| 55 packageDirs = (packageDirs != null | 62 packageDirs = (packageDirs != null |
| 56 ? packageDirs : _readPackageDirsFromPub(currentPackage)); | 63 ? packageDirs : _readPackageDirsFromPub(currentPackage)); |
| 57 | 64 |
| 58 } | 65 } |
| 59 | 66 |
| 60 /** | 67 /** |
| 61 * Creates a barback system as specified by [options] and runs it. Returns a | 68 * Creates a barback system as specified by [options] and runs it. Returns a |
| 62 * future that contains the list of assets generated after barback runs to | 69 * future that contains the list of assets generated after barback runs to |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 'stack_trace', 'template_binding', 'unittest', 'unmodifiable_collection', | 123 'stack_trace', 'template_binding', 'unittest', 'unmodifiable_collection', |
| 117 'yaml'].toSet(); | 124 'yaml'].toSet(); |
| 118 | 125 |
| 119 /** Return the relative path of each file under [subDir] in [package]. */ | 126 /** Return the relative path of each file under [subDir] in [package]. */ |
| 120 Iterable<String> _listPackageDir(String package, String subDir, | 127 Iterable<String> _listPackageDir(String package, String subDir, |
| 121 BarbackOptions options) { | 128 BarbackOptions options) { |
| 122 var packageDir = options.packageDirs[package]; | 129 var packageDir = options.packageDirs[package]; |
| 123 if (packageDir == null) return const []; | 130 if (packageDir == null) return const []; |
| 124 var dir = new Directory(path.join(packageDir, subDir)); | 131 var dir = new Directory(path.join(packageDir, subDir)); |
| 125 if (!dir.existsSync()) return const []; | 132 if (!dir.existsSync()) return const []; |
| 126 return dir.listSync(recursive: true, followLinks: false) | 133 return dir.listSync(recursive: true, followLinks: options.followLinks) |
| 127 .where((f) => f is File) | 134 .where((f) => f is File) |
| 128 .map((f) => path.relative(f.path, from: packageDir)); | 135 .map((f) => path.relative(f.path, from: packageDir)); |
| 129 } | 136 } |
| 130 | 137 |
| 131 /** A simple provider that reads files directly from the pub cache. */ | 138 /** A simple provider that reads files directly from the pub cache. */ |
| 132 class _PolymerPackageProvider implements PackageProvider { | 139 class _PolymerPackageProvider implements PackageProvider { |
| 133 Map<String, String> packageDirs; | 140 Map<String, String> packageDirs; |
| 134 Iterable<String> get packages => packageDirs.keys; | 141 Iterable<String> get packages => packageDirs.keys; |
| 135 | 142 |
| 136 _PolymerPackageProvider(this.packageDirs); | 143 _PolymerPackageProvider(this.packageDirs); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 output.write(entry.span.getLocationMessage(entry.message, | 375 output.write(entry.span.getLocationMessage(entry.message, |
| 369 useColors: useColors, | 376 useColors: useColors, |
| 370 color: levelColor)); | 377 color: levelColor)); |
| 371 } | 378 } |
| 372 return output.toString(); | 379 return output.toString(); |
| 373 } | 380 } |
| 374 | 381 |
| 375 const String _RED_COLOR = '\u001b[31m'; | 382 const String _RED_COLOR = '\u001b[31m'; |
| 376 const String _MAGENTA_COLOR = '\u001b[35m'; | 383 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 377 const String _NO_COLOR = '\u001b[0m'; | 384 const String _NO_COLOR = '\u001b[0m'; |
| OLD | NEW |