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

Unified Diff: utils/pub/command_update.dart

Issue 10214006: Refactor command code and add support for --help and --version. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
Index: utils/pub/command_update.dart
diff --git a/utils/pub/command_update.dart b/utils/pub/command_update.dart
index c1fe4f4816b65723c926c8684b30c3770c32da77..c932ebe149a7784316d0d04fc0ee6e5f2c1d4b3e 100644
--- a/utils/pub/command_update.dart
+++ b/utils/pub/command_update.dart
@@ -3,6 +3,27 @@
// BSD-style license that can be found in the LICENSE file.
/** Handles the `update` pub command. */
-void commandUpdate(PubOptions options, List<String> args) {
- throw 'not implemented yet';
+class UpdateCommand extends PubCommand {
+ String get description() => "update a package's dependencies";
nweiz 2012/04/25 20:49:41 "update the current package's dependencies to the
Bob Nystrom 2012/04/25 22:56:40 Done.
+
+ void onRun() {
+ var entrypoint;
+ var packagesDir;
+ var dependencies;
+
+ getWorkingPackage().chain((package) {
+ entrypoint = package;
+ return package.traverseDependencies(cache);
+ }).chain((packages) {
+ dependencies = packages;
+ // TODO(rnystrom): Make this path configurable.
+ packagesDir = join(entrypoint.dir, 'packages');
+ return cleanDir(packagesDir);
+ }).then((dir) {
+ // Symlink each dependency.
+ for (final package in dependencies) {
+ createSymlink(package.dir, join(packagesDir, package.name));
+ }
+ });
+ }
}

Powered by Google App Engine
This is Rietveld 408576698