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