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, 'gist-shortcut-package')
16 name: 'gist-shortcut-package',
19 'private-gist': 'gist:foo/deadbeef'
23 test('setup', function (t) {
28 test('gist-shortcut-package', function (t) {
30 ['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
31 ['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
32 ['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
34 var npm = requireInject.installGlobally('../../lib/npm.js', {
36 'execFile': function (cmd, args, options, cb) {
37 process.nextTick(function () {
38 if (args[0] !== 'clone') return cb(null, '', '')
39 var cloneUrl = cloneUrls.shift()
41 t.is(args[3], cloneUrl[0], cloneUrl[1])
43 t.fail('too many attempts to clone')
52 cache: path.resolve(pkg, 'cache'),
54 registry: common.registry,
57 npm.load(opts, function (er) {
58 t.ifError(er, 'npm loaded without error')
59 npm.commands.install([], function (er, result) {
60 t.ok(er, 'mocked install failed as expected')
66 test('cleanup', function (t) {
75 path.join(pkg, 'package.json'),
76 JSON.stringify(json, null, 2)
82 process.chdir(osenv.tmpdir())