Chromium Code Reviews| Index: utils/pub/sdk_source.dart |
| diff --git a/utils/pub/sdk_source.dart b/utils/pub/sdk_source.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b79dde21e815c384f4e5404095d9deff9b1a8944 |
| --- /dev/null |
| +++ b/utils/pub/sdk_source.dart |
| @@ -0,0 +1,34 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * A package source that uses libraries from the Dart SDK. |
| + * |
| + * This currently uses the "sdkdir" command-line argument to find the SDK. |
| + */ |
| +// TODO(nweiz): This should read the SDK directory from an environment variable |
| +// once we can set those for tests. |
| +class SdkSource extends Source { |
| + final String name = "sdk"; |
| + final bool shouldCache = false; |
| + |
| + /** |
| + * The root directory of the Dart SDK. |
| + */ |
| + final String rootDir; |
| + |
| + SdkSource(this.rootDir); |
| + |
| + /** |
| + * Since all the SDK files are already available locally, installation just |
| + * involves symlinking the SDK library into the packages directory. |
| + */ |
| + Future<bool> install(PackageId id, String destPath) { |
| + var sourcePath = join(rootDir, "lib", id.name); |
|
Bob Nystrom
2012/05/03 00:15:49
Might want to look in utils too at some point.
nweiz
2012/05/04 01:03:43
Something to talk to Dan about.
|
| + return exists(sourcePath).chain((exists) { |
| + if (!exists) return new Future<bool>.immediate(false); |
| + return createSymlink(sourcePath, destPath).transform((_) => true); |
| + }); |
| + } |
| +} |