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-https-url-with-creds-package')
16 name: 'bitbucket-https-url-with-creds-package',
19 'private': 'git+https://user:pass@bitbucket.org/foo/private.git'
23 test('setup', function (t) {
28 test('bitbucket-https-url-with-creds-package', function (t) {
30 ['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
33 var npm = requireInject.installGlobally('../../lib/npm.js', {
35 'execFile': function (cmd, args, options, cb) {
36 process.nextTick(function () {
37 if (args[0] !== 'clone') return cb(null, '', '')
38 var cloneUrl = cloneUrls.shift()
40 t.is(args[3], cloneUrl[0], cloneUrl[1])
42 t.fail('too many attempts to clone')
51 cache: path.resolve(pkg, 'cache'),
53 registry: common.registry,
56 npm.load(opts, function (er) {
57 t.ifError(er, 'npm loaded without error')
58 npm.commands.install([], function (er) {
59 t.ok(er, 'mocked install failed as expected')
65 test('cleanup', function (t) {
74 path.join(pkg, 'package.json'),
75 JSON.stringify(json, null, 2)
81 process.chdir(osenv.tmpdir())