1var fs = require('fs') 2var path = require('path') 3 4var test = require('tap').test 5var mkdirp = require('mkdirp') 6var rimraf = require('rimraf') 7var common = require('../common-tap.js') 8 9var pkg = common.pkg 10 11test('setup', function (t) { 12 mkdirp.sync(pkg) 13 fs.writeFileSync( 14 path.join(pkg, 'package.json'), 15 JSON.stringify({ 16 name: 'publish-access', 17 version: '1.2.5' 18 })) 19 t.pass('setup done') 20 t.end() 21}) 22 23test('unscoped packages cannot be restricted', function (t) { 24 var args = ['--access=restricted', '--loglevel=warn', '--registry=' + common.registry] 25 var opts = {stdio: [0, 1, 'pipe'], cwd: pkg} 26 common.npm(['publish'].concat(args), opts, function (err, code, stdout, stderr) { 27 if (err) throw err 28 t.notEqual(code, 0, 'publish not successful') 29 t.match(stderr, "Can't restrict access to unscoped packages.") 30 31 t.end() 32 }) 33}) 34 35test('cleanup', function (t) { 36 rimraf.sync(pkg) 37 t.end() 38}) 39