| 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 // We get very long filenames which can cause us to not be able to delete | 219 if (dir.existsSync()) dir.deleteSync(recursive: true); |
| 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 runInShell: true); | |
| 225 if (result.exitCode != 0) { | |
| 226 throw "Could not delete $dir, output was: \n" | |
| 227 "stdout: ${result.stdout} \n" | |
| 228 "stderr: ${result.stderr}"; | |
| 229 } | |
| 230 } else { | |
| 231 dir.deleteSync(recursive: true); | |
| 232 } | |
| 233 } | |
| 234 return _emitPackagesDir(options) | 220 return _emitPackagesDir(options) |
| 235 .then((_) => _emitTransformedFiles(assets, options)) | 221 .then((_) => _emitTransformedFiles(assets, options)) |
| 236 .then((_) => _addPackagesSymlinks(assets, options)) | 222 .then((_) => _addPackagesSymlinks(assets, options)) |
| 237 .then((_) => assets); | 223 .then((_) => assets); |
| 238 }); | 224 }); |
| 239 } | 225 } |
| 240 | 226 |
| 241 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { | 227 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { |
| 242 // Copy all the assets we transformed | 228 // Copy all the assets we transformed |
| 243 var futures = []; | 229 var futures = []; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 output.write(entry.span.getLocationMessage(entry.message, | 361 output.write(entry.span.getLocationMessage(entry.message, |
| 376 useColors: useColors, | 362 useColors: useColors, |
| 377 color: levelColor)); | 363 color: levelColor)); |
| 378 } | 364 } |
| 379 return output.toString(); | 365 return output.toString(); |
| 380 } | 366 } |
| 381 | 367 |
| 382 const String _RED_COLOR = '\u001b[31m'; | 368 const String _RED_COLOR = '\u001b[31m'; |
| 383 const String _MAGENTA_COLOR = '\u001b[35m'; | 369 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 384 const String _NO_COLOR = '\u001b[0m'; | 370 const String _NO_COLOR = '\u001b[0m'; |
| OLD | NEW |