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, 'bitbucket-shortcut')
16 name: 'bitbucket-shortcut',
20 test('setup', function (t) {
25 test('bitbucket-shortcut', function (t) {
27 ['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'],
28 ['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second']
31 var npm = requireInject.installGlobally('../../lib/npm.js', {
33 'execFile': function (cmd, args, options, cb) {
34 process.nextTick(function () {
35 if (args[0] !== 'clone') return cb(null, '', '')
36 var cloneUrl = cloneUrls.shift()
38 t.is(args[3], cloneUrl[0], cloneUrl[1])
40 t.fail('too many attempts to clone')
49 cache: path.resolve(pkg, 'cache'),
51 registry: common.registry,
54 npm.load(opts, function (er) {
55 t.ifError(er, 'npm loaded without error')
56 npm.commands.install(['bitbucket:foo/private'], function (er) {
57 t.ok(er, 'mocked install failed as expected')
63 test('cleanup', function (t) {
72 path.join(pkg, 'package.json'),
73 JSON.stringify(json, null, 2)
79 process.chdir(osenv.tmpdir())