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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 */ | 58 */ |
59 Future<AssetSet> runBarback(BarbackOptions options) { | 59 Future<AssetSet> runBarback(BarbackOptions options) { |
60 var barback = new Barback(new _PolymerPackageProvider(options.packageDirs)); | 60 var barback = new Barback(new _PolymerPackageProvider(options.packageDirs)); |
61 _initBarback(barback, options); | 61 _initBarback(barback, options); |
62 _attachListeners(barback); | 62 _attachListeners(barback); |
63 if (options.outDir == null) return barback.getAllAssets(); | 63 if (options.outDir == null) return barback.getAllAssets(); |
64 return _emitAllFiles(barback, options); | 64 return _emitAllFiles(barback, options); |
65 } | 65 } |
66 | 66 |
67 /** Extract the current package from the pubspec.yaml file. */ | 67 /** Extract the current package from the pubspec.yaml file. */ |
68 String readCurrentPackageFromPubspec() { | 68 String readCurrentPackageFromPubspec([String dir]) { |
69 var pubspec = new File('pubspec.yaml'); | 69 var pubspec = new File( |
| 70 dir == null ? 'pubspec.yaml' : path.join(dir, 'pubspec.yaml')); |
70 if (!pubspec.existsSync()) { | 71 if (!pubspec.existsSync()) { |
71 print('error: pubspec.yaml file not found, please run this script from ' | 72 print('error: pubspec.yaml file not found, please run this script from ' |
72 'your package root directory.'); | 73 'your package root directory.'); |
73 return null; | 74 return null; |
74 } | 75 } |
75 return loadYaml(pubspec.readAsStringSync())['name']; | 76 return loadYaml(pubspec.readAsStringSync())['name']; |
76 } | 77 } |
77 | 78 |
78 /** | 79 /** |
79 * Extract a mapping between package names and the path in the file system where | 80 * Extract a mapping between package names and the path in the file system where |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 Future _copyFile(String inpath, String outpath) { | 303 Future _copyFile(String inpath, String outpath) { |
303 _ensureDir(path.dirname(outpath)); | 304 _ensureDir(path.dirname(outpath)); |
304 return new File(inpath).openRead().pipe(new File(outpath).openWrite()); | 305 return new File(inpath).openRead().pipe(new File(outpath).openWrite()); |
305 } | 306 } |
306 | 307 |
307 /** Write contents of an [asset] into a file at [filepath]. */ | 308 /** Write contents of an [asset] into a file at [filepath]. */ |
308 Future _writeAsset(String filepath, Asset asset) { | 309 Future _writeAsset(String filepath, Asset asset) { |
309 _ensureDir(path.dirname(filepath)); | 310 _ensureDir(path.dirname(filepath)); |
310 return asset.read().pipe(new File(filepath).openWrite()); | 311 return asset.read().pipe(new File(filepath).openWrite()); |
311 } | 312 } |
OLD | NEW |