1var fs = require('graceful-fs') 2var http = require('http') 3var path = require('path') 4 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8var pkg = common.pkg 9var fixturePath = path.join(pkg, 'fixture_npmrc') 10 11var json = { 12 name: 'npm-test-unpublish-config', 13 version: '1.2.3', 14 publishConfig: { registry: common.registry } 15} 16 17test('setup', function (t) { 18 fs.writeFileSync( 19 path.join(pkg, 'package.json'), 20 JSON.stringify(json), 'utf8' 21 ) 22 fs.writeFileSync( 23 fixturePath, 24 '//localhost:' + common.port + '/:_authToken = beeeeeeeeeeeeef\n' + 25 'registry = http://lvh.me:4321/registry/path\n' 26 ) 27 28 t.end() 29}) 30 31test('cursory test of unpublishing with config', function (t) { 32 var child 33 t.plan(4) 34 http.createServer(function (req, res) { 35 t.pass('got request on the fakey fake registry') 36 this.close() 37 res.statusCode = 500 38 res.end(JSON.stringify({ 39 error: 'shh no tears, only dreams now' 40 })) 41 child.kill('SIGINT') 42 }).listen(common.port, function () { 43 t.pass('server is listening') 44 45 child = common.npm( 46 [ 47 '--userconfig', fixturePath, 48 '--loglevel', 'error', 49 '--force', 50 'unpublish' 51 ], 52 { 53 cwd: pkg, 54 stdio: 'inherit', 55 env: { 56 'npm_config_cache_lock_stale': 1000, 57 'npm_config_cache_lock_wait': 1000, 58 HOME: process.env.HOME, 59 Path: process.env.PATH, 60 PATH: process.env.PATH, 61 USERPROFILE: process.env.USERPROFILE 62 } 63 }, 64 function (err, code) { 65 t.ifError(err, 'publish command finished successfully') 66 t.notOk(code, 'npm install exited with code 0') 67 } 68 ) 69 }) 70}) 71