Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-11-25 04:18:53 +0300
committerisaacs <i@izs.me>2010-11-25 04:33:05 +0300
commit9eaa3dc2c447bb4149f2e8df1627b0f510399eff (patch)
tree2725824d058a35c5bac7229bd915628ec6c5dd25
parent691083015d3c725c0d3865f0d2d79060d96e7d80 (diff)
Edit command
-rw-r--r--doc/edit.md22
-rw-r--r--lib/edit.js24
-rw-r--r--man1/edit.132
-rw-r--r--npm.js1
4 files changed, 79 insertions, 0 deletions
diff --git a/doc/edit.md b/doc/edit.md
new file mode 100644
index 000000000..6d8d1a6c7
--- /dev/null
+++ b/doc/edit.md
@@ -0,0 +1,22 @@
+npm-edit(1) -- Edit an installed package
+========================================
+
+## SYNOPSIS
+
+ npm edit <pkg>[@<version>]
+
+## DESCRIPTION
+
+Opens the package folder in the default editor (or whatever you've
+configured as the npm `editor` config -- see `npm help config`.)
+
+After it has been edited, the package is rebuilt so as to pick up any
+changes in compiled packages.
+
+Note: If you're finding yourself using this a lot, it's probably better
+to use `npm link` instead. However, it is extremely handy when used in
+conjunction with `npm bundle`.
+
+For instance, you can do `npm bundle install connect` to install connect
+into your package, and then `npm bundle edit connect` to make a few
+changes to your locally bundled copy.
diff --git a/lib/edit.js b/lib/edit.js
new file mode 100644
index 000000000..ff174b3cc
--- /dev/null
+++ b/lib/edit.js
@@ -0,0 +1,24 @@
+// npm edit <pkg>[@<version>]
+// open the package folder in the $EDITOR
+
+module.exports = edit
+edit.usage = "npm edit <pkg>[@<version>]"
+
+var npm = require("../npm")
+ , exec = require("./utils/exec")
+ , path = require("path")
+
+function edit (args, cb) {
+ var p = args[0]
+ p = p.split("@")
+ if (args.length !== 1 || !p) return cb(edit.usage)
+ var editor = npm.config.get("editor")
+ , n = p.shift()
+ , v = p.join("@") || "active"
+ if (!editor) return cb(new Error(
+ "No editor set. Set the 'editor' config, or $EDITOR environ."))
+ exec(editor, [path.join(npm.dir, n, v, "package")], function (er) {
+ if (er) return cb(er)
+ npm.commands.rebuild(args, cb)
+ })
+}
diff --git a/man1/edit.1 b/man1/edit.1
new file mode 100644
index 000000000..72ca09448
--- /dev/null
+++ b/man1/edit.1
@@ -0,0 +1,32 @@
+.\" Generated with Ronnjs/v0.1
+.\" http://github.com/kapouer/ronnjs/
+.
+.TH "NPM\-EDIT" "1" "November 2010" "" ""
+.
+.SH "NAME"
+\fBnpm-edit\fR \-\- Edit an installed package
+.
+.SH "SYNOPSIS"
+.
+.nf
+npm edit <pkg>[@<version>]
+.
+.fi
+.
+.SH "DESCRIPTION"
+Opens the package folder in the default editor (or whatever you\'ve
+configured as the npm \fBeditor\fR config \-\- see \fBnpm help config\fR\|\.)
+.
+.P
+After it has been edited, the package is rebuilt so as to pick up any
+changes in compiled packages\.
+.
+.P
+Note: If you\'re finding yourself using this a lot, it\'s probably better
+to use \fBnpm link\fR instead\. However, it is extremely handy when used in
+conjunction with \fBnpm bundle\fR\|\.
+.
+.P
+For instance, you can do \fBnpm bundle install connect\fR to install connect
+into your package, and then \fBnpm bundle edit connect\fR to make a few
+changes to your locally bundled copy\.
diff --git a/npm.js b/npm.js
index 459f8ee1c..21ba6d148 100644
--- a/npm.js
+++ b/npm.js
@@ -82,6 +82,7 @@ var commandCache = {}
, "completion"
, "deprecate"
, "version"
+ , "edit"
]
, fullList = npm.fullList = cmdList.concat(aliasNames)
, abbrevs = abbrev(fullList)