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 /// Definitions used to run the polymer linter and deploy tools without using | 5 /// Definitions used to run the polymer linter and deploy tools without using |
6 /// pub serve or pub deploy. | 6 /// pub serve or pub deploy. |
7 library polymer.src.build.runner; | 7 library polymer.src.build.runner; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 }); | 210 }); |
211 } | 211 } |
212 | 212 |
213 /// Emits all outputs of [barback] and copies files that we didn't process (like | 213 /// Emits all outputs of [barback] and copies files that we didn't process (like |
214 /// dependent package's libraries). | 214 /// dependent package's libraries). |
215 Future _emitAllFiles(Barback barback, BarbackOptions options) { | 215 Future _emitAllFiles(Barback barback, BarbackOptions options) { |
216 return barback.getAllAssets().then((assets) { | 216 return barback.getAllAssets().then((assets) { |
217 // Delete existing output folder before we generate anything | 217 // Delete existing output folder before we generate anything |
218 var dir = new Directory(options.outDir); | 218 var dir = new Directory(options.outDir); |
219 if (dir.existsSync()) dir.deleteSync(recursive: true); | 219 // We get very long filenames which can cause us to not be able to delete |
| 220 // using the normal dart:io deleteSync(recursive: true) on windows |
| 221 if (dir.existsSync()) { |
| 222 if (Platform.operatingSystem == 'windows' ) { |
| 223 var result = Process.runSync('rmdir', ['/q', '/s', options.outDir]); |
| 224 if (result.exitCode != 0) { |
| 225 throw "Could not delete $dir, output was: \n" |
| 226 "stdout: ${result.stdout} \n" |
| 227 "stderr: ${result.stderr}"; |
| 228 } |
| 229 } else { |
| 230 dir.deleteSync(recursive: true); |
| 231 } |
| 232 } |
220 return _emitPackagesDir(options) | 233 return _emitPackagesDir(options) |
221 .then((_) => _emitTransformedFiles(assets, options)) | 234 .then((_) => _emitTransformedFiles(assets, options)) |
222 .then((_) => _addPackagesSymlinks(assets, options)) | 235 .then((_) => _addPackagesSymlinks(assets, options)) |
223 .then((_) => assets); | 236 .then((_) => assets); |
224 }); | 237 }); |
225 } | 238 } |
226 | 239 |
227 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { | 240 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { |
228 // Copy all the assets we transformed | 241 // Copy all the assets we transformed |
229 var futures = []; | 242 var futures = []; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 output.write(entry.span.getLocationMessage(entry.message, | 374 output.write(entry.span.getLocationMessage(entry.message, |
362 useColors: useColors, | 375 useColors: useColors, |
363 color: levelColor)); | 376 color: levelColor)); |
364 } | 377 } |
365 return output.toString(); | 378 return output.toString(); |
366 } | 379 } |
367 | 380 |
368 const String _RED_COLOR = '\u001b[31m'; | 381 const String _RED_COLOR = '\u001b[31m'; |
369 const String _MAGENTA_COLOR = '\u001b[35m'; | 382 const String _MAGENTA_COLOR = '\u001b[35m'; |
370 const String _NO_COLOR = '\u001b[0m'; | 383 const String _NO_COLOR = '\u001b[0m'; |
OLD | NEW |