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
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-05-10 11:36:29 +0400
committerisaacs <i@izs.me>2010-05-10 11:36:29 +0400
commitca139022d648ae63f1b806ac3ae0aaeba9f20c79 (patch)
treefff401b58a6bfe914a7c955a64d43d634055d732 /lib
parenteace3883c55c5f5af5843c80abab39a1dba9548b (diff)
Make publish awesome
Use the registry and the cache to do crazy stuff, like publish a local tarball or folder. Also, package tarballs are added to the registry as couchdb attachments, so there's no reliance on github, and it's less likely that tarballs will go away or change after being published.
Diffstat (limited to 'lib')
-rw-r--r--lib/publish.js37
1 files changed, 7 insertions, 30 deletions
diff --git a/lib/publish.js b/lib/publish.js
index ee4e569ae..b8e6e3442 100644
--- a/lib/publish.js
+++ b/lib/publish.js
@@ -19,34 +19,11 @@ var fs = require("fs")
, url = require("url")
function publish (args, cb) {
- var tarball = args.shift()
- , u = url.parse(tarball)
-
- if (!(u && u.protocol && u.host)) {
- return cb(new Error("Invalid remote tarball url: "+tarball))
- }
-
- var targetDir = path.join(npm.tmp,
- tarball.replace(/[^a-zA-Z0-9]/g, "-")+"-"+ Date.now()+"-"+Math.random())
- , targetFile = targetDir + ".tgz"
-
- chain
- ( [mkdir, targetDir]
- , [fetch, tarball, targetFile]
- , [unpackTar, targetFile, targetDir]
- , function (cb) {
- readJson(path.join(targetDir, "package.json"), function (er, data) {
- if (er) return cb(er)
- registry.publish(data, tarball, cb)
- })
- }
- // cleanup
- , [rm, targetFile]
- , [rm, targetDir]
- , cb
- )
-}
-
-function unpackTar (tarball, unpackTarget, cb) {
- exec("tar", ["xzvf", tarball, "--strip", "1", "-C", unpackTarget], cb)
+ log(args, "publish")
+ npm.commands.cache.add(args[0], args[1], function (er, data) {
+ if (er) return cb(er)
+ log(data, "publish")
+ if (!data) return cb(new Error("no data!?"))
+ registry.publish(data, cb)
+ })
}