| 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 * A package source that uses libraries from the Dart SDK. | 6 * A package source that uses libraries from the Dart SDK. |
| 7 * | 7 * |
| 8 * This currently uses the "sdkdir" command-line argument to find the SDK. | 8 * This currently uses the "sdkdir" command-line argument to find the SDK. |
| 9 */ | 9 */ |
| 10 // TODO(nweiz): This should read the SDK directory from an environment variable | 10 // TODO(nweiz): This should read the SDK directory from an environment variable |
| 11 // once we can set those for tests. | 11 // once we can set those for tests. |
| 12 class SdkSource extends Source { | 12 class SdkSource extends Source { |
| 13 final String name = "sdk"; | 13 final String name = "sdk"; |
| 14 final bool shouldCache = false; | 14 final bool shouldCache = false; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * The root directory of the Dart SDK. | 17 * The root directory of the Dart SDK. |
| 18 */ | 18 */ |
| 19 final String rootDir; | 19 final String rootDir; |
| 20 | 20 |
| 21 SdkSource(this.rootDir); | 21 SdkSource(this.rootDir); |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Since all the SDK files are already available locally, installation just | 24 * Since all the SDK files are already available locally, installation just |
| 25 * involves symlinking the SDK library into the packages directory. | 25 * involves symlinking the SDK library into the packages directory. |
| 26 */ | 26 */ |
| 27 Future<bool> install(PackageId id, String destPath) { | 27 Future<bool> install(PackageId id, String destPath) { |
| 28 var sourcePath = join(rootDir, "lib", id.fullName); | 28 var sourcePath = join(rootDir, "lib", id.description); |
| 29 return exists(sourcePath).chain((exists) { | 29 return exists(sourcePath).chain((exists) { |
| 30 if (!exists) return new Future<bool>.immediate(false); | 30 if (!exists) return new Future<bool>.immediate(false); |
| 31 return createSymlink(sourcePath, destPath).transform((_) => true); | 31 return createSymlink(sourcePath, destPath).transform((_) => true); |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 } | 34 } |
| OLD | NEW |