1 if (process.platform === "win32") {
2 console.error("skipping test, because windows and shebangs")
6 var common = require("../common-tap.js")
7 var mr = require("npm-registry-mock")
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')
18 var opts = { cwd: __dirname }
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")
29 test("npm repo underscore", function (t) {
30 mr({port : common.port}, function (er, s) {
33 '--registry=' + common.registry,
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')
40 t.equal(res, "https://github.com/jashkenas/underscore\n")
48 test('npm repo optimist - github (https://)', function (t) {
49 mr({port : common.port}, function (er, s) {
52 '--registry=' + common.registry,
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')
59 t.equal(res, "https://github.com/substack/node-optimist\n")
66 test("npm repo npm-test-peer-deps - no repo", function (t) {
67 mr({port : common.port}, function (er, s) {
69 'repo', 'npm-test-peer-deps',
70 '--registry=' + common.registry,
72 '--browser=' + __dirname + '/_script.sh'
73 ], opts, function (err, code, stdout, stderr) {
74 t.equal(code, 1, 'exit not ok')
81 test("npm repo test-repo-url-http - non-github (http://)", function (t) {
82 mr({port : common.port}, function (er, s) {
84 'repo', 'test-repo-url-http',
85 '--registry=' + common.registry,
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')
92 t.equal(res, "http://gitlab.com/evanlucas/test-repo-url-http\n")
99 test("npm repo test-repo-url-https - non-github (https://)", function (t) {
100 mr({port : common.port}, function (er, s) {
102 'repo', 'test-repo-url-https',
103 '--registry=' + common.registry,
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')
110 t.equal(res, "https://gitlab.com/evanlucas/test-repo-url-https\n")
117 test("npm repo test-repo-url-ssh - non-github (ssh://)", function (t) {
118 mr({port : common.port}, function (er, s) {
120 'repo', 'test-repo-url-ssh',
121 '--registry=' + common.registry,
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')
128 t.equal(res, "http://gitlab.com/evanlucas/test-repo-url-ssh\n")
135 test("cleanup", function (t) {
136 fs.unlinkSync(__dirname + "/_script.sh")