summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/publish-access-unscoped-restricted-fails.js')
-rw-r--r--deps/npm/test/tap/publish-access-unscoped-restricted-fails.js58
1 files changed, 17 insertions, 41 deletions
diff --git a/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js b/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
index 4c7fce7351..660d0f48d7 100644
--- a/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
+++ b/deps/npm/test/tap/publish-access-unscoped-restricted-fails.js
@@ -4,59 +4,35 @@ var path = require('path')
var test = require('tap').test
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
-
-var npm = require('../../')
var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'publish-access-unscoped')
test('setup', function (t) {
- mkdirp(path.join(pkg, 'cache'), function () {
- var configuration = {
- cache: path.join(pkg, 'cache'),
- loglevel: 'silent',
- registry: common.registry
- }
-
- npm.load(configuration, next)
- })
-
- function next (er) {
- t.ifError(er, 'npm loaded successfully')
-
- process.chdir(pkg)
- fs.writeFile(
- path.join(pkg, 'package.json'),
- JSON.stringify({
- name: 'publish-access',
- version: '1.2.5'
- }),
- 'ascii',
- function (er) {
- t.ifError(er)
-
- t.pass('setup done')
- t.end()
- }
- )
- }
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify({
+ name: 'publish-access',
+ version: '1.2.5'
+ }))
+ t.pass('setup done')
+ t.end()
})
test('unscoped packages cannot be restricted', function (t) {
- npm.config.set('access', 'restricted')
- npm.commands.publish([], false, function (er) {
- t.ok(er, 'got an error back')
- t.equal(er.message, "Can't restrict access to unscoped packages.")
+ var args = ['--access=restricted', '--loglevel=warn', '--registry=' + common.registry]
+ var opts = {stdio: [0, 1, 'pipe'], cwd: pkg}
+ common.npm(['publish'].concat(args), opts, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.notEqual(code, 0, 'publish not successful')
+ t.match(stderr, "Can't restrict access to unscoped packages.")
t.end()
})
})
test('cleanup', function (t) {
- process.chdir(__dirname)
- rimraf(pkg, function (er) {
- t.ifError(er)
-
- t.end()
- })
+ rimraf.sync(pkg)
+ t.end()
})