Chromium Code Reviews| Index: utils/pub/io.dart |
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart |
| index 82614ca68af23db08cc7fa8d07b6d62a2d14e5b0..fcfba5cb9f391f1c9ebcf9b8f9bdb1abbe8b07e8 100644 |
| --- a/utils/pub/io.dart |
| +++ b/utils/pub/io.dart |
| @@ -264,15 +264,23 @@ Future _attemptRetryable(Future callback()) { |
| return makeAttempt(null); |
| } |
| -/// Creates a new symlink that creates an alias from [from] to [to]. Returns a |
| -/// [Future] which completes to the symlink file (i.e. [to]). |
| +/// Creates a new symlink at path [symlink] that points to [target]. Returns a |
| +/// [Future] which completes to the symlink file. |
|
nweiz
2013/02/15 23:09:24
"to the path to the symlink file"; same below
Bob Nystrom
2013/02/16 00:09:57
Done.
|
| +/// |
| +/// If [relative] is true, creates a symlink with a relative path from the |
| +/// symlink to the target. Otherwise, uses the [target] path unmodified. |
| /// |
| /// Note that on Windows, only directories may be symlinked to. |
| -Future<String> createSymlink(String from, String to) { |
| - log.fine("Creating symlink ($to is a symlink to $from)"); |
| +Future<String> createSymlink(String symlink, String target, |
|
nweiz
2013/02/15 23:09:24
I don't like the parameter reordering here. It sho
Bob Nystrom
2013/02/16 00:09:57
It's always going to be wrong for one OS. I found
nweiz
2013/02/16 01:02:14
The way it is now is wrong for all but one OS, and
Bob Nystrom
2013/02/16 01:19:03
Done.
|
| + {bool relative: false}) { |
| + if (relative) { |
| + target = path.normalize(path.relative(target, from: path.dirname(symlink))); |
| + } |
| + |
| + log.fine("Creating $symlink pointing to $target"); |
| var command = 'ln'; |
| - var args = ['-s', from, to]; |
| + var args = ['-s', target, symlink]; |
| if (Platform.operatingSystem == 'windows') { |
| // Call mklink on Windows to create an NTFS junction point. Only works on |
| @@ -281,24 +289,29 @@ Future<String> createSymlink(String from, String to) { |
| // link (/d) because the latter requires some privilege shenanigans that |
| // I'm not sure how to specify from the command line. |
| command = 'mklink'; |
| - args = ['/j', to, from]; |
| + args = ['/j', symlink, target]; |
| } |
| // TODO(rnystrom): Check exit code and output? |
| - return runProcess(command, args).then((result) => to); |
| + return runProcess(command, args).then((result) => symlink); |
| } |
| -/// Creates a new symlink that creates an alias from the `lib` directory of |
| -/// package [from] to [to]. Returns a [Future] which completes to the symlink |
| -/// file (i.e. [to]). If [from] does not have a `lib` directory, this shows a |
| +/// Creates a new symlink that creates an alias at [symlink] that points to the |
| +/// `lib` directory of package [target]. Returns a [Future] which completes to |
| +/// the symlink file. If [target] does not have a `lib` directory, this shows a |
| /// warning if appropriate and then does nothing. |
| -Future<String> createPackageSymlink(String name, String from, String to, |
| - {bool isSelfLink: false}) { |
| +/// |
| +/// If [relative] is true, creates a symlink with a relative path from the |
| +/// symlink to the target. Otherwise, uses the [target] path unmodified. |
| +Future<String> createPackageSymlink(String name, String symlink, String target, |
| + {bool isSelfLink: false, bool relative: false}) { |
| return defer(() { |
| // See if the package has a "lib" directory. |
| - from = path.join(from, 'lib'); |
| + target = path.join(target, 'lib'); |
| log.fine("Creating ${isSelfLink ? "self" : ""}link for package '$name'."); |
| - if (dirExists(from)) return createSymlink(from, to); |
| + if (dirExists(target)) { |
| + return createSymlink(symlink, target, relative: relative); |
| + } |
| // It's OK for the self link (i.e. the root package) to not have a lib |
| // directory since it may just be a leaf application that only has |
| @@ -308,7 +321,7 @@ Future<String> createPackageSymlink(String name, String from, String to, |
| 'you will not be able to import any libraries from it.'); |
| } |
| - return to; |
| + return symlink; |
| }); |
| } |