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 rimraf = require("rimraf")
11 var fs = require("fs")
12 var path = require("path")
14 var outFile = path.join(__dirname, "/_output")
16 var opts = { cwd: __dirname }
18 test("setup", function (t) {
19 var s = "#!/usr/bin/env bash\n" +
20 "echo \"$@\" > " + JSON.stringify(__dirname) + "/_output\n"
21 fs.writeFileSync(join(__dirname, "/_script.sh"), s, "ascii")
22 fs.chmodSync(join(__dirname, "/_script.sh"), "0755")
27 test("npm bugs underscore", function (t) {
28 mr({port : common.port}, function (er, s) {
31 "--registry=" + common.registry,
33 "--browser=" + join(__dirname, "/_script.sh")
34 ], opts, function (err, code, stdout, stderr) {
35 t.ifError(err, "bugs ran without issue")
36 t.notOk(stderr, "should have no stderr")
37 t.equal(code, 0, "exit ok")
38 var res = fs.readFileSync(outFile, "ascii")
40 t.equal(res, "https://github.com/jashkenas/underscore/issues\n")
47 test("npm bugs optimist - github (https://)", function (t) {
48 mr({port : common.port}, function (er, s) {
51 "--registry=" + common.registry,
53 "--browser=" + join(__dirname, "/_script.sh")
54 ], opts, function (err, code, stdout, stderr) {
55 t.ifError(err, "bugs ran without issue")
56 t.notOk(stderr, "should have no stderr")
57 t.equal(code, 0, "exit ok")
58 var res = fs.readFileSync(outFile, "ascii")
60 t.equal(res, "https://github.com/substack/node-optimist/issues\n")
67 test("npm bugs npm-test-peer-deps - no repo", function (t) {
68 mr({port : common.port}, function (er, s) {
70 "bugs", "npm-test-peer-deps",
71 "--registry=" + common.registry,
73 "--browser=" + join(__dirname, "/_script.sh")
74 ], opts, function (err, code, stdout, stderr) {
75 t.ifError(err, "bugs ran without issue")
76 t.notOk(stderr, "should have no stderr")
77 t.equal(code, 0, "exit ok")
78 var res = fs.readFileSync(outFile, "ascii")
80 t.equal(res, "https://www.npmjs.org/package/npm-test-peer-deps\n")
87 test("npm bugs test-repo-url-http - non-github (http://)", function (t) {
88 mr({port : common.port}, function (er, s) {
90 "bugs", "test-repo-url-http",
91 "--registry=" + common.registry,
93 "--browser=" + join(__dirname, "/_script.sh")
94 ], opts, function (err, code, stdout, stderr) {
95 t.ifError(err, "bugs ran without issue")
96 t.notOk(stderr, "should have no stderr")
97 t.equal(code, 0, "exit ok")
98 var res = fs.readFileSync(outFile, "ascii")
100 t.equal(res, "https://www.npmjs.org/package/test-repo-url-http\n")
107 test("npm bugs test-repo-url-https - non-github (https://)", function (t) {
108 mr({port : common.port}, function (er, s) {
110 "bugs", "test-repo-url-https",
111 "--registry=" + common.registry,
113 "--browser=" + join(__dirname, "/_script.sh")
114 ], opts, function (err, code, stdout, stderr) {
115 t.ifError(err, "bugs ran without issue")
116 t.notOk(stderr, "should have no stderr")
117 t.equal(code, 0, "exit ok")
118 var res = fs.readFileSync(outFile, "ascii")
120 t.equal(res, "https://www.npmjs.org/package/test-repo-url-https\n")
127 test("npm bugs test-repo-url-ssh - non-github (ssh://)", function (t) {
128 mr({port : common.port}, function (er, s) {
130 "bugs", "test-repo-url-ssh",
131 "--registry=" + common.registry,
133 "--browser=" + join(__dirname, "/_script.sh")
134 ], opts, function (err, code, stdout, stderr) {
135 t.ifError(err, "bugs ran without issue")
136 t.notOk(stderr, "should have no stderr")
137 t.equal(code, 0, "exit ok")
138 var res = fs.readFileSync(outFile, "ascii")
140 t.equal(res, "https://www.npmjs.org/package/test-repo-url-ssh\n")
147 test("cleanup", function (t) {
148 fs.unlinkSync(join(__dirname, "/_script.sh"))