1 var common = require("../common-tap.js")
2 var test = require("tap").test
4 var osenv = require("osenv")
5 var pkg = process.env.npm_config_tmp || "/tmp"
6 pkg += "/npm-test-publish-config"
8 require("mkdirp").sync(pkg)
10 fs.writeFileSync(pkg + "/package.json", JSON.stringify({
11 name: "npm-test-publish-config",
13 publishConfig: { registry: common.registry }
16 fs.writeFileSync(pkg + "/fixture_npmrc",
17 "//localhost:1337/:email = fancy@feast.net\n" +
18 "//localhost:1337/:username = fancy\n" +
19 "//localhost:1337/:_password = " + new Buffer("feast").toString("base64") + "\n" +
20 "registry = http://localhost:1337/")
25 require("http").createServer(function (req, res) {
26 t.pass("got request on the fakey fake registry")
29 res.end(JSON.stringify({
30 error: "sshhh. naptime nao. \\^O^/ <(YAWWWWN!)"
33 }).listen(common.port, function () {
34 t.pass("server is listening")
36 // don't much care about listening to the child's results
37 // just wanna make sure it hits the server we just set up.
39 // there are plenty of other tests to verify that publish
40 // itself functions normally.
42 // Make sure that we don't sit around waiting for lock files
43 child = common.npm(["publish", "--userconfig=" + pkg + "/fixture_npmrc"], {
47 "npm_config_cache_lock_stale": 1000,
48 "npm_config_cache_lock_wait": 1000,
49 HOME: process.env.HOME,
50 Path: process.env.PATH,
51 PATH: process.env.PATH,
52 USERPROFILE: osenv.home()
54 }, function (err, code) {
55 t.ifError(err, "publish command finished successfully")
56 t.notOk(code, "npm install exited with code 0")