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({
33 test('setup', function (t) {
35 setup(function (er, r) {
41 daemon = r[r.length - 2]
42 daemonPID = r[r.length - 1]
49 test('install from repo on \'Windows\'', function (t) {
50 // before we confuse everything by switching the platform
51 require('../../lib/install.js')
52 require('../../lib/unbuild.js')
53 process.platform = 'win32'
55 npm.commands.install('.', [], function (er) {
56 t.ifError(er, 'npm installed via git')
62 test('clean', function (t) {
63 daemon.on('close', function () {
67 process.kill(daemonPID)
70 function bootstrap () {
73 fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
79 fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
80 npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
81 // some really cheesy monkeypatching
82 require('module')._cache[require.resolve('which')] = {
83 exports: function (_, cb) { cb() }
85 git = require('../../lib/utils/git.js')
87 function startDaemon (cb) {
102 stdio: ['pipe', 'pipe', 'pipe']
105 d.stderr.on('data', childFinder)
107 function childFinder (c) {
108 var cpid = c.toString().match(/^\[(\d+)\]/)
110 this.removeListener('data', childFinder)
111 cb(null, [d, cpid[1]])
120 ['clone', '--bare', repo, 'child.git'],
121 { cwd: pkg, env: process.env }
129 function cleanup () {
130 process.chdir(osenv.tmpdir())