2 var resolve = require('path').resolve
4 var osenv = require('osenv')
5 var mkdirp = require('mkdirp')
6 var rimraf = require('rimraf')
7 var test = require('tap').test
9 var npm = require('../../lib/npm.js')
10 var common = require('../common-tap.js')
12 var pkg = resolve(__dirname, 'add-remote-git')
13 var repo = resolve(__dirname, 'add-remote-git-repo')
19 var pjParent = JSON.stringify({
23 child: 'git://localhost:1234/child.git'
27 var pjChild = JSON.stringify({
32 test('setup', function (t) {
34 setup(function (er, r) {
35 t.ifError(er, 'git started up successfully')
38 daemon = r[r.length - 2]
39 daemonPID = r[r.length - 1]
46 test('install from repo', function (t) {
48 npm.commands.install('.', [], function (er) {
49 t.ifError(er, 'npm installed via git')
55 test('clean', function (t) {
56 daemon.on('close', function () {
60 process.kill(daemonPID)
63 function bootstrap () {
65 fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
70 fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
71 npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
72 git = require('../../lib/utils/git.js')
74 function startDaemon (cb) {
89 stdio: ['pipe', 'pipe', 'pipe']
92 d.stderr.on('data', childFinder)
94 function childFinder (c) {
95 var cpid = c.toString().match(/^\[(\d+)\]/)
97 this.removeListener('data', childFinder)
98 cb(null, [d, cpid[1]])
107 ['clone', '--bare', repo, 'child.git'],
108 { cwd: pkg, env: process.env }
116 function cleanup () {
117 process.chdir(osenv.tmpdir())