npm: Upgrade to 1.3.17
[platform/upstream/nodejs.git] / deps / npm / test / tap / publish-config.js
1 var common = require('../common-tap.js')
2 var test = require('tap').test
3 var fs = require('fs')
4 var osenv = require('osenv')
5 var pkg = process.env.npm_config_tmp || '/tmp'
6 pkg += '/npm-test-publish-config'
7
8 require('mkdirp').sync(pkg)
9
10 fs.writeFileSync(pkg + '/package.json', JSON.stringify({
11   name: 'npm-test-publish-config',
12   version: '1.2.3',
13   publishConfig: { registry: common.registry }
14 }), 'utf8')
15
16 var spawn = require('child_process').spawn
17 var npm = require.resolve('../../bin/npm-cli.js')
18 var node = process.execPath
19
20 test(function (t) {
21   var child
22   require('http').createServer(function (req, res) {
23     t.pass('got request on the fakey fake registry')
24     t.end()
25     this.close()
26     res.statusCode = 500
27     res.end('{"error":"sshhh. naptime nao. \\^O^/ <(YAWWWWN!)"}')
28     child.kill()
29   }).listen(common.port, function () {
30     t.pass('server is listening')
31
32     // don't much care about listening to the child's results
33     // just wanna make sure it hits the server we just set up.
34     //
35     // there are plenty of other tests to verify that publish
36     // itself functions normally.
37     //
38     // Make sure that we don't sit around waiting for lock files
39     child = spawn(node, [npm, 'publish', '--email=fancy', '--_auth=feast'], {
40       cwd: pkg,
41       env: {
42         npm_config_cache_lock_stale: 1000,
43         npm_config_cache_lock_wait: 1000,
44         HOME: process.env.HOME,
45         Path: process.env.PATH,
46         PATH: process.env.PATH,
47         USERPROFILE: osenv.home()
48       }
49     })
50   })
51 })