]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/repo.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / repo.js
1 if (process.platform === "win32") {
2   console.error("skipping test, because windows and shebangs")
3   return
4 }
5
6 var common = require("../common-tap.js")
7 var mr = require("npm-registry-mock")
8
9 var test = require("tap").test
10 var npm = require.resolve("../../bin/npm-cli.js")
11 var node = process.execPath
12 var rimraf = require("rimraf")
13 var spawn = require("child_process").spawn
14 var fs = require("fs")
15 var path = require('path')
16 var outFile = path.join(__dirname, '/_output')
17
18 var opts = { cwd: __dirname }
19
20 test("setup", function (t) {
21   var s = "#!/usr/bin/env bash\n" +
22           "echo \"$@\" > " + JSON.stringify(__dirname) + "/_output\n"
23   fs.writeFileSync(__dirname + "/_script.sh", s, "ascii")
24   fs.chmodSync(__dirname + "/_script.sh", "0755")
25   t.pass("made script")
26   t.end()
27 })
28
29 test("npm repo underscore", function (t) {
30   mr({port : common.port}, function (er, s) {
31     common.npm([
32       'repo', 'underscore',
33       '--registry=' + common.registry,
34       '--loglevel=silent',
35       '--browser=' + __dirname + '/_script.sh'
36     ], opts, function (err, code, stdout, stderr) {
37       t.equal(code, 0, 'exit ok')
38       var res = fs.readFileSync(outFile, 'ascii')
39       s.close()
40       t.equal(res, "https://github.com/jashkenas/underscore\n")
41       rimraf.sync(outFile)
42       t.end()
43     })
44   })
45 })
46
47
48 test('npm repo optimist - github (https://)', function (t) {
49   mr({port : common.port}, function (er, s) {
50     common.npm([
51       'repo', 'optimist',
52       '--registry=' + common.registry,
53       '--loglevel=silent',
54       '--browser=' + __dirname + '/_script.sh'
55     ], opts, function (err, code, stdout, stderr) {
56       t.equal(code, 0, 'exit ok')
57       var res = fs.readFileSync(outFile, 'ascii')
58       s.close()
59       t.equal(res, "https://github.com/substack/node-optimist\n")
60       rimraf.sync(outFile)
61       t.end()
62     })
63   })
64 })
65
66 test("npm repo npm-test-peer-deps - no repo", function (t) {
67   mr({port : common.port}, function (er, s) {
68     common.npm([
69       'repo', 'npm-test-peer-deps',
70       '--registry=' + common.registry,
71       '--loglevel=silent',
72       '--browser=' + __dirname + '/_script.sh'
73     ], opts, function (err, code, stdout, stderr) {
74       t.equal(code, 1, 'exit not ok')
75       s.close()
76       t.end()
77     })
78   })
79 })
80
81 test("npm repo test-repo-url-http - non-github (http://)", function (t) {
82   mr({port : common.port}, function (er, s) {
83     common.npm([
84       'repo', 'test-repo-url-http',
85       '--registry=' + common.registry,
86       '--loglevel=silent',
87       '--browser=' + __dirname + '/_script.sh'
88     ], opts, function (err, code, stdout, stderr) {
89       t.equal(code, 0, 'exit ok')
90       var res = fs.readFileSync(outFile, 'ascii')
91       s.close()
92       t.equal(res, "http://gitlab.com/evanlucas/test-repo-url-http\n")
93       rimraf.sync(outFile)
94       t.end()
95     })
96   })
97 })
98
99 test("npm repo test-repo-url-https - non-github (https://)", function (t) {
100   mr({port : common.port}, function (er, s) {
101     common.npm([
102       'repo', 'test-repo-url-https',
103       '--registry=' + common.registry,
104       '--loglevel=silent',
105       '--browser=' + __dirname + '/_script.sh'
106     ], opts, function (err, code, stdout, stderr) {
107       t.equal(code, 0, 'exit ok')
108       var res = fs.readFileSync(outFile, 'ascii')
109       s.close()
110       t.equal(res, "https://gitlab.com/evanlucas/test-repo-url-https\n")
111       rimraf.sync(outFile)
112       t.end()
113     })
114   })
115 })
116
117 test("npm repo test-repo-url-ssh - non-github (ssh://)", function (t) {
118   mr({port : common.port}, function (er, s) {
119     common.npm([
120       'repo', 'test-repo-url-ssh',
121       '--registry=' + common.registry,
122       '--loglevel=silent',
123       '--browser=' + __dirname + '/_script.sh'
124     ], opts, function (err, code, stdout, stderr) {
125       t.equal(code, 0, 'exit ok')
126       var res = fs.readFileSync(outFile, 'ascii')
127       s.close()
128       t.equal(res, "http://gitlab.com/evanlucas/test-repo-url-ssh\n")
129       rimraf.sync(outFile)
130       t.end()
131     })
132   })
133 })
134
135 test("cleanup", function (t) {
136   fs.unlinkSync(__dirname + "/_script.sh")
137   t.pass("cleaned up")
138   t.end()
139 })