| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 library io; | 8 library io; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 * | 324 * |
| 325 * Unlike [createSymlink], this has heuristics to detect if [from] is using | 325 * Unlike [createSymlink], this has heuristics to detect if [from] is using |
| 326 * the old or new style of package layout. If it's using the new style, then | 326 * the old or new style of package layout. If it's using the new style, then |
| 327 * it will create a symlink to the "lib" directory contained inside that | 327 * it will create a symlink to the "lib" directory contained inside that |
| 328 * package directory. Otherwise, it just symlinks to the package directory | 328 * package directory. Otherwise, it just symlinks to the package directory |
| 329 * itself. | 329 * itself. |
| 330 */ | 330 */ |
| 331 // TODO(rnystrom): Remove this when old style packages are no longer supported. | 331 // TODO(rnystrom): Remove this when old style packages are no longer supported. |
| 332 // See: http://code.google.com/p/dart/issues/detail?id=4964. | 332 // See: http://code.google.com/p/dart/issues/detail?id=4964. |
| 333 Future<File> createPackageSymlink(String name, from, to, | 333 Future<File> createPackageSymlink(String name, from, to, |
| 334 [bool isSelfLink = false]) { | 334 {bool isSelfLink: false}) { |
| 335 // If from contains any Dart files at the top level (aside from build.dart) | 335 // If from contains any Dart files at the top level (aside from build.dart) |
| 336 // we assume that means it's an old style package. | 336 // we assume that means it's an old style package. |
| 337 return listDir(from).chain((contents) { | 337 return listDir(from).chain((contents) { |
| 338 var isOldStyle = contents.some( | 338 var isOldStyle = contents.some( |
| 339 (file) => file.endsWith('.dart') && basename(file) != 'build.dart'); | 339 (file) => file.endsWith('.dart') && basename(file) != 'build.dart'); |
| 340 | 340 |
| 341 if (isOldStyle) { | 341 if (isOldStyle) { |
| 342 if (isSelfLink) { | 342 if (isSelfLink) { |
| 343 printError('Warning: Package "$name" is using a deprecated layout.'); | 343 printError('Warning: Package "$name" is using a deprecated layout.'); |
| 344 printError('See http://www.dartlang.org/docs/pub-package-manager/' | 344 printError('See http://www.dartlang.org/docs/pub-package-manager/' |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 return new Directory(entry); | 754 return new Directory(entry); |
| 755 } | 755 } |
| 756 | 756 |
| 757 /** | 757 /** |
| 758 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 758 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 759 */ | 759 */ |
| 760 Uri _getUri(uri) { | 760 Uri _getUri(uri) { |
| 761 if (uri is Uri) return uri; | 761 if (uri is Uri) return uri; |
| 762 return new Uri.fromString(uri); | 762 return new Uri.fromString(uri); |
| 763 } | 763 } |
| OLD | NEW |