2 var path = require("path")
4 var test = require("tap").test
5 var mkdirp = require("mkdirp")
6 var rimraf = require("rimraf")
8 var npm = require("../../")
9 var common = require("../common-tap.js")
11 var pkg = path.join(__dirname, "publish-access-unscoped")
13 // TODO: nock uses setImmediate, breaks 0.8: replace with mockRegistry
14 if (!global.setImmediate) {
15 global.setImmediate = function () {
16 var args = [arguments[0], 0].concat([].slice.call(arguments, 1))
17 setTimeout.apply(this, args)
21 test("setup", function (t) {
22 mkdirp(path.join(pkg, "cache"), function () {
24 cache : path.join(pkg, "cache"),
26 registry : common.registry
29 npm.load(configuration, next)
33 t.ifError(er, "npm loaded successfully")
37 path.join(pkg, "package.json"),
39 name: "publish-access",
53 test("unscoped packages cannot be restricted", function (t) {
54 npm.config.set("access", "restricted")
55 npm.commands.publish([], false, function (er) {
56 t.ok(er, "got an error back")
57 t.equal(er.message, "Can't restrict access to unscoped packages.")
63 test("cleanup", function (t) {
64 process.chdir(__dirname)
65 rimraf(pkg, function (er) {