2 var fs = require('graceful-fs')
3 var path = require('path')
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var requireInject = require('require-inject')
8 var rimraf = require('rimraf')
9 var test = require('tap').test
11 var common = require('../common-tap.js')
13 var pkg = path.resolve(__dirname, 'gitlab-shortcut')
16 name: 'gitlab-shortcut',
20 test('setup', function (t) {
25 test('gitlab-shortcut', function (t) {
27 ['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first'],
28 ['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second']
30 var npm = requireInject.installGlobally('../../lib/npm.js', {
32 'execFile': function (cmd, args, options, cb) {
33 process.nextTick(function () {
34 if (args[0] !== 'clone') return cb(null, '', '')
35 var cloneUrl = cloneUrls.shift()
37 t.is(args[3], cloneUrl[0], cloneUrl[1])
39 t.fail('too many attempts to clone')
48 cache: path.resolve(pkg, 'cache'),
50 registry: common.registry,
53 npm.load(opts, function (er) {
54 t.ifError(er, 'npm loaded without error')
55 npm.commands.install(['gitlab:foo/private'], function (er, result) {
56 t.ok(er, 'mocked install failed as expected')
62 test('cleanup', function (t) {
71 path.join(pkg, 'package.json'),
72 JSON.stringify(json, null, 2)
78 process.chdir(osenv.tmpdir())