| Index: utils/pub/io.dart
|
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart
|
| index 1d9b82416e3eb91b86e0ca41499e48134701fb7e..3f54fcdd915cac4bc05e4dafd5d77f119ff3c5b8 100644
|
| --- a/utils/pub/io.dart
|
| +++ b/utils/pub/io.dart
|
| @@ -29,11 +29,13 @@ bool isBeneath(String entry, String dir) {
|
| return !path.isAbsolute(relative) && path.split(relative)[0] != '..';
|
| }
|
|
|
| -/// Determines if a file or directory at [path] exists.
|
| -bool entryExists(String path) => fileExists(path) || dirExists(path);
|
| +/// Determines if a file or directory exists at [path].
|
| +bool entryExists(String path) => dirExists(path) || fileExists(path);
|
|
|
| -/// Determines if [file] exists on the file system.
|
| -bool fileExists(String file) => new File(file).existsSync();
|
| +/// Determines if [file] exists on the file system. Will also return `true` if
|
| +/// [file] points to a symlink, even a directory symlink.
|
| +bool fileExists(String file) =>
|
| + new File(file).existsSync() || new Link(file).existsSync();
|
|
|
| /// Reads the contents of the text file [file].
|
| String readTextFile(String file) =>
|
| @@ -212,10 +214,16 @@ Future<String> cleanDir(String dir) {
|
| if (dirExists(dir)) {
|
| // Delete it first.
|
| return deleteDir(dir).then((_) => createDir(dir));
|
| - } else {
|
| - // Just create it.
|
| + }
|
| +
|
| + if (fileExists(dir)) {
|
| + // If there is a non-directory there (file or symlink), delete it.
|
| + deleteFile(dir);
|
| return createDir(dir);
|
| }
|
| +
|
| + // Just create it.
|
| + return createDir(dir);
|
| });
|
| }
|
|
|
|
|