]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/publish-access-unscoped-restricted-fails.js
4d39b00b16702de5179b0bdee323ed4071969591
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / publish-access-unscoped-restricted-fails.js
1 var fs = require("fs")
2 var path = require("path")
3
4 var test = require("tap").test
5 var mkdirp = require("mkdirp")
6 var rimraf = require("rimraf")
7
8 var npm = require("../../")
9 var common = require("../common-tap.js")
10
11 var pkg = path.join(__dirname, "publish-access-unscoped")
12
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)
18   }
19 }
20
21 test("setup", function (t) {
22   mkdirp(path.join(pkg, "cache"), function () {
23     var configuration = {
24       cache    : path.join(pkg, "cache"),
25       loglevel : "silent",
26       registry : common.registry
27     }
28
29     npm.load(configuration, next)
30   })
31
32   function next (er) {
33     t.ifError(er, "npm loaded successfully")
34
35     process.chdir(pkg)
36     fs.writeFile(
37       path.join(pkg, "package.json"),
38       JSON.stringify({
39         name: "publish-access",
40         version: "1.2.5"
41       }),
42       "ascii",
43       function (er) {
44         t.ifError(er)
45
46         t.pass("setup done")
47         t.end()
48       }
49     )
50   }
51 })
52
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.")
58
59     t.end()
60   })
61 })
62
63 test("cleanup", function (t) {
64   process.chdir(__dirname)
65   rimraf(pkg, function (er) {
66     t.ifError(er)
67
68     t.end()
69   })
70 })