| 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 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
| 6 library io; | 6 library io; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 /// Creates a new symlink that creates an alias from the `lib` directory of | 393 /// Creates a new symlink that creates an alias from the `lib` directory of |
| 394 /// package [from] to [to], both of which can be a [String], [File], or | 394 /// package [from] to [to], both of which can be a [String], [File], or |
| 395 /// [Directory]. Returns a [Future] which completes to the symlink file (i.e. | 395 /// [Directory]. Returns a [Future] which completes to the symlink file (i.e. |
| 396 /// [to]). If [from] does not have a `lib` directory, this shows a warning if | 396 /// [to]). If [from] does not have a `lib` directory, this shows a warning if |
| 397 /// appropriate and then does nothing. | 397 /// appropriate and then does nothing. |
| 398 Future<File> createPackageSymlink(String name, from, to, | 398 Future<File> createPackageSymlink(String name, from, to, |
| 399 {bool isSelfLink: false}) { | 399 {bool isSelfLink: false}) { |
| 400 // See if the package has a "lib" directory. | 400 // See if the package has a "lib" directory. |
| 401 from = join(from, 'lib'); | 401 // Note(Sam): Relative paths causes issues when cwd is different. |
| 402 // also, absolute paths are safer when app is moved around. |
| 403 from = getFullPath(join(from, 'lib')); |
| 402 return dirExists(from).then((exists) { | 404 return dirExists(from).then((exists) { |
| 403 log.fine("Creating ${isSelfLink ? "self" : ""}link for package '$name'."); | 405 log.fine("Creating ${isSelfLink ? "self" : ""}link for package '$name'."); |
| 404 if (exists) return createSymlink(from, to); | 406 if (exists) return createSymlink(from, to); |
| 405 | 407 |
| 406 // It's OK for the self link (i.e. the root package) to not have a lib | 408 // It's OK for the self link (i.e. the root package) to not have a lib |
| 407 // directory since it may just be a leaf application that only has | 409 // directory since it may just be a leaf application that only has |
| 408 // code in bin or web. | 410 // code in bin or web. |
| 409 if (!isSelfLink) { | 411 if (!isSelfLink) { |
| 410 log.warning('Warning: Package "$name" does not have a "lib" directory so ' | 412 log.warning('Warning: Package "$name" does not have a "lib" directory so ' |
| 411 'you will not be able to import any libraries from it.'); | 413 'you will not be able to import any libraries from it.'); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 Directory _getDirectory(entry) { | 1032 Directory _getDirectory(entry) { |
| 1031 if (entry is Directory) return entry; | 1033 if (entry is Directory) return entry; |
| 1032 return new Directory(entry); | 1034 return new Directory(entry); |
| 1033 } | 1035 } |
| 1034 | 1036 |
| 1035 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 1037 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 1036 Uri _getUri(uri) { | 1038 Uri _getUri(uri) { |
| 1037 if (uri is Uri) return uri; | 1039 if (uri is Uri) return uri; |
| 1038 return new Uri.fromString(uri); | 1040 return new Uri.fromString(uri); |
| 1039 } | 1041 } |
| OLD | NEW |