]> 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-scoped.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / publish-scoped.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 var common = require('../common-tap')
8 var mr = require('npm-registry-mock')
9
10 var pkg = path.join(__dirname, "prepublish_package")
11
12 var server
13
14 function setup () {
15   cleanup()
16   mkdirp.sync(path.join(pkg, 'cache'))
17
18   fs.writeFileSync(
19     path.join(pkg, 'package.json'),
20     JSON.stringify({
21       name: '@bigco/publish-organized',
22       version: '1.2.5'
23     }, null, 2),
24     'ascii')
25 }
26
27 test('setup', function (t) {
28   setup()
29   mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
30     t.ifError(err, 'registry mocked successfully')
31     server = s
32     t.end()
33   })
34 })
35
36 test('npm publish should honor scoping', function (t) {
37   server.filteringRequestBody(verify)
38         .put('/@bigco%2fpublish-organized', true)
39         .reply(201, {ok: true})
40
41   var configuration = [
42     'progress=false',
43     'cache=' + path.join(pkg, 'cache'),
44     'registry=http://nonexistent.lvh.me',
45     '//localhost:1337/:username=username',
46     '//localhost:1337/:_password=' + new Buffer('password').toString('base64'),
47     '//localhost:1337/:email=' + 'ogd@aoaioxxysz.net',
48     '@bigco:registry=' + common.registry
49   ]
50   var configFile = path.join(pkg, '.npmrc')
51
52   fs.writeFileSync(configFile, configuration.join('\n') + '\n')
53
54   common.npm(['publish'], {'cwd': pkg}, function (err, code, stdout, stderr) {
55     if (err) throw err
56     t.is(code, 0, 'published without error')
57     server.done()
58     t.end()
59   })
60
61   function verify (body) {
62     t.doesNotThrow(function () {
63       var parsed = JSON.parse(body)
64       var current = parsed.versions["1.2.5"]
65       t.equal(
66         current._npmVersion,
67         require(path.resolve(__dirname, "../../package.json")).version,
68         "npm version is correct"
69       )
70
71       t.equal(
72         current._nodeVersion,
73         process.versions.node,
74         "node version is correct"
75       )
76     }, "converted body back into object")
77
78     return true
79   }
80 })
81
82 test('cleanup', function (t) {
83   server.close()
84   t.end()
85   cleanup()
86 })
87
88 function cleanup () {
89   process.chdir(__dirname)
90   rimraf.sync(pkg)
91 }