2 var resolve = require('path').resolve
3 var url = require('url')
5 var osenv = require('osenv')
6 var mkdirp = require('mkdirp')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
10 var npm = require('../../lib/npm.js')
11 var common = require('../common-tap.js')
13 var pkg = resolve(__dirname, 'add-remote-git-file')
14 var repo = resolve(__dirname, 'add-remote-git-file-repo')
17 var cloneURL = 'git+file://' + resolve(pkg, 'child.git')
19 var pjChild = JSON.stringify({
24 test('setup', function (t) {
26 setup(function (er, r) {
27 t.ifError(er, 'git started up successfully')
33 test('cache from repo', function (t) {
35 var addRemoteGit = require('../../lib/cache/add-remote-git.js')
36 addRemoteGit(cloneURL, function (er, data) {
37 t.ifError(er, 'cached via git')
39 url.parse(data._resolved).protocol,
41 'npm didn\'t go crazy adding git+git+git+git'
48 test('clean', function (t) {
53 function bootstrap () {
60 fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
61 npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
62 git = require('../../lib/utils/git.js')
66 commands: [git.chainableExec(
67 ['clone', '--bare', repo, 'child.git'],
68 { cwd: pkg, env: process.env }
75 process.chdir(osenv.tmpdir())