Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: utils/pub/sdk_source.dart

Issue 10340005: Add support for pub install. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b64fd9c78014a9ce4f0dc8cc83c7005efdfd3566
--- /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.fullName);
+ return exists(sourcePath).chain((exists) {
+ if (!exists) return new Future<bool>.immediate(false);
+ return createSymlink(sourcePath, destPath).transform((_) => true);
+ });
+ }
+}
« no previous file with comments | « utils/pub/pub.dart ('k') | utils/pub/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698