From e61e68dac4fa51c0540a064204a75b19f8052e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 30 May 2017 22:04:55 -0700 Subject: publish: adapt config for publish RegClient (#16762) Fixes: #16746 PR-URL: https://github.com/npm/npm/pull/16762 Credit: @zkat --- test/tap/publish-config.js | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/tap/publish-config.js b/test/tap/publish-config.js index 399fd0f93..fb430af21 100644 --- a/test/tap/publish-config.js +++ b/test/tap/publish-config.js @@ -1,36 +1,43 @@ -var common = require('../common-tap.js') -var test = require('tap').test -var fs = require('fs') -var osenv = require('osenv') -var pkg = process.env.npm_config_tmp || '/tmp' -pkg += '/npm-test-publish-config' +'use strict' + +const common = require('../common-tap.js') +const test = require('tap').test +const fs = require('fs') +const osenv = require('osenv') +const pkg = `${process.env.npm_config_tmp || '/tmp'}/npm-test-publish-config` require('mkdirp').sync(pkg) fs.writeFileSync(pkg + '/package.json', JSON.stringify({ name: 'npm-test-publish-config', version: '1.2.3', - publishConfig: { registry: common.registry } + publishConfig: { + registry: common.registry + } }), 'utf8') fs.writeFileSync(pkg + '/fixture_npmrc', '//localhost:1337/:email = fancy@feast.net\n' + '//localhost:1337/:username = fancy\n' + - '//localhost:1337/:_password = ' + new Buffer('feast').toString('base64') + '\n' + - 'registry = http://localhost:1337/') + '//localhost:1337/:_password = ' + new Buffer('feast').toString('base64')) test(function (t) { - var child - t.plan(4) + let child + t.plan(5) require('http').createServer(function (req, res) { t.pass('got request on the fakey fake registry') - this.close() - res.statusCode = 500 - res.end(JSON.stringify({ - error: 'sshhh. naptime nao. \\^O^/ <(YAWWWWN!)' - })) - child.kill('SIGINT') - }).listen(common.port, function () { + let body = '' + req.on('data', (d) => { body += d }) + req.on('end', () => { + this.close() + res.statusCode = 500 + res.end(JSON.stringify({ + error: 'sshhh. naptime nao. \\^O^/ <(YAWWWWN!)' + })) + t.match(body, /"beta"/, 'got expected tag') + child.kill('SIGINT') + }) + }).listen(common.port, () => { t.pass('server is listening') // don't much care about listening to the child's results @@ -40,7 +47,7 @@ test(function (t) { // itself functions normally. // // Make sure that we don't sit around waiting for lock files - child = common.npm(['publish', '--userconfig=' + pkg + '/fixture_npmrc'], { + child = common.npm(['publish', '--userconfig=' + pkg + '/fixture_npmrc', '--tag=beta'], { cwd: pkg, stdio: 'inherit', env: { -- cgit v1.2.3