Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Add bundle destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Dec 6, 2010
1 parent d7ab4c3 commit 85b372b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion doc/bundle.md
Expand Up @@ -3,7 +3,9 @@ npm-bundle(1) -- Bundle package dependencies


## SYNOPSIS ## SYNOPSIS


npm bundle [<cmd> ...] npm bundle
npm bundle destroy
npm bundle <cmd> <args>


Run in a package folder. Run in a package folder.


Expand All @@ -21,6 +23,8 @@ dependencies that already exist in the bundle.
To bundle all the dependencies of a given package, run `npm bundle` To bundle all the dependencies of a given package, run `npm bundle`
without any arguments. without any arguments.


To completely remove the bundle folder, run `npm bundle destroy`.

To operate on the bundle packages, any npm command and arguments may be To operate on the bundle packages, any npm command and arguments may be
passed to the `npm bundle` command. For example, to install a package passed to the `npm bundle` command. For example, to install a package
into the bundle, you can do `npm bundle install express`. into the bundle, you can do `npm bundle install express`.
Expand Down
9 changes: 8 additions & 1 deletion lib/bundle.js
Expand Up @@ -9,19 +9,21 @@ var npm = require("../npm")
, mkdir = require("./utils/mkdir-p") , mkdir = require("./utils/mkdir-p")
, fs = require("./utils/graceful-fs") , fs = require("./utils/graceful-fs")
, conf = require("./utils/ini").configList , conf = require("./utils/ini").configList
, rm = require("./utils/rm-rf")
, notAllowed = [ "adduser", "build", "bundle", "config", "init", "link" , notAllowed = [ "adduser", "build", "bundle", "config", "init", "link"
, "owner", "publish", "restart", "start", "stop", "tag" , "owner", "publish", "restart", "start", "stop", "tag"
, "unpublish", "update-dependents", "view" ] , "unpublish", "update-dependents", "view" ]


bundle.usage = "npm bundle\n" bundle.usage = "npm bundle\n"
+ "npm bundle destroy\n"
+ "npm bundle <cmd> <args>\n" + "npm bundle <cmd> <args>\n"
+ "(run in package dir)" + "(run in package dir)"


bundle.completion = function(args, index, cb) { bundle.completion = function(args, index, cb) {
var getCompletions = require("./utils/completion/get-completions") var getCompletions = require("./utils/completion/get-completions")
, subcmdList = npm.fullList.filter(function(c) { , subcmdList = npm.fullList.filter(function(c) {
return notAllowed.indexOf(c) === -1 return notAllowed.indexOf(c) === -1
}) }).concat(["destroy"])
, subcmd = args[0] || "" , subcmd = args[0] || ""


if (subcmdList.indexOf(subcmd) !== -1) { if (subcmdList.indexOf(subcmd) !== -1) {
Expand Down Expand Up @@ -63,6 +65,11 @@ function bundle (args, cb_) {
if (cmd === npm.commands.ls) c.registry = null if (cmd === npm.commands.ls) c.registry = null
} }


if (cmd === "destroy") return rm(location, function (er) {
if (er) return cb(er)
log.info(location, "destroyed", cb)
})

mkdir(npm.dir, function(er) { mkdir(npm.dir, function(er) {
if (er) return log.er(cb, "Error creating "+npm.dir+" for bundling")(er) if (er) return log.er(cb, "Error creating "+npm.dir+" for bundling")(er)
if (typeof cmd === "function") { if (typeof cmd === "function") {
Expand Down
7 changes: 6 additions & 1 deletion man1/bundle.1
Expand Up @@ -9,7 +9,9 @@
.SH "SYNOPSIS" .SH "SYNOPSIS"
. .
.nf .nf
npm bundle [<cmd> \.\.\.] npm bundle
npm bundle destroy
npm bundle <cmd> <args>
. .
.fi .fi
. .
Expand All @@ -33,6 +35,9 @@ To bundle all the dependencies of a given package, run \fBnpm bundle\fR
without any arguments\. without any arguments\.
. .
.P .P
To completely remove the bundle folder, run \fBnpm bundle destroy\fR\|\.
.
.P
To operate on the bundle packages, any npm command and arguments may be To operate on the bundle packages, any npm command and arguments may be
passed to the \fBnpm bundle\fR command\. For example, to install a package passed to the \fBnpm bundle\fR command\. For example, to install a package
into the bundle, you can do \fBnpm bundle install express\fR\|\. into the bundle, you can do \fBnpm bundle install express\fR\|\.
Expand Down

0 comments on commit 85b372b

Please sign in to comment.