Skip to content

Commit

Permalink
Edit command
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 25, 2010
1 parent 6910830 commit 9eaa3dc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/edit.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 24 additions & 0 deletions lib/edit.js
Original file line number Diff line number Diff line change
@@ -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)
})
}
32 changes: 32 additions & 0 deletions man1/edit.1
Original file line number Diff line number Diff line change
@@ -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\.
1 change: 1 addition & 0 deletions npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var commandCache = {}
, "completion"
, "deprecate"
, "version"
, "edit"
]
, fullList = npm.fullList = cmdList.concat(aliasNames)
, abbrevs = abbrev(fullList)
Expand Down

0 comments on commit 9eaa3dc

Please sign in to comment.