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

Commit

Permalink
Support name@version in cache add
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Oct 15, 2010
1 parent 4885fe4 commit dc1dc1e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ var mkdir = require("./utils/mkdir-p")
, registry = require("./utils/registry")
, log = require("./utils/log")
, path = require("path")
, sys = require("sys")
, sys = require("./utils/sys")

cache.usage = "npm cache add <tarball file>"
+ "\nnpm cache add <folder>"
+ "\nnpm cache add <tarball url>"
+ "\nnpm cache add <name> <version>"
+ "\nnpm cache add <name>@<version>"
+ "\nnpm cache ls [<path>]"
+ "\nnpm cache clean [<pkg> [<version>]]"
+ "\nnpm cache clean [<pkg>[@<version>]]"

function cache (args, cb) {
var cmd = args.shift()
Expand Down Expand Up @@ -55,8 +55,11 @@ function read (name, ver, cb) {
})
}

// npm cache ls [<pkg> [<ver>]]
// npm cache ls [<pkg>[@<ver>]]
function ls (args, cb) {
if (args[0] && args[0].indexOf("@") !== -1) {
args = args[0].split("@")
}
var show = path.join.apply(path, args)
, read = npm.cache
, msg = "cache ls"+(show?" "+show:"")
Expand All @@ -82,6 +85,9 @@ function ls (args, cb) {
function clean (args, cb) {
if (!cb) cb = args, args = []
if (!args) args = []
if (args[0] && args[0].indexOf("@") !== -1) {
args = args[0].split("@")
}
var pkg = args.shift()
, ver = args.shift()
, clean = npm.cache
Expand All @@ -101,6 +107,9 @@ exports.add = function (pkg, ver, cb) {
return add([pkg, ver], cb)
}
function add (args, cb) {
if (args[0] && args[0].indexOf("@") !== -1) {
args = args[0].split("@")
}
var pkg = args.shift()
, ver = args.shift()
if (!pkg && !ver) {
Expand Down

0 comments on commit dc1dc1e

Please sign in to comment.