1'use strict' 2var test = require('tap').test 3var common = require('../common-tap.js') 4var path = require('path') 5var rimraf = require('rimraf') 6var mkdirp = require('mkdirp') 7var basepath = path.resolve(__dirname, path.basename(__filename, '.js')) 8var fixturepath = path.resolve(basepath, 'npm-test-bundled-git') 9var modulepath = path.resolve(basepath, 'node_modules') 10var installedpath = path.resolve(modulepath, 'npm-test-bundled-git') 11var Tacks = require('tacks') 12var File = Tacks.File 13var Dir = Tacks.Dir 14 15var minimatchExpected = { 16 name: 'minimatch', 17 description: 'a glob matcher in javascript', 18 version: '0.2.1', 19 repository: { 20 type: 'git', 21 url: 'git://github.com/isaacs/minimatch.git' 22 }, 23 main: 'minimatch.js', 24 scripts: { 25 test: 'tap test' 26 }, 27 engines: { 28 node: '*' 29 }, 30 dependencies: { 31 'lru-cache': '~1.0.5' 32 }, 33 devDependencies: { 34 tap: '~0.1.3' 35 }, 36 licenses: [ 37 { 38 type: 'MIT', 39 url: 'http://github.com/isaacs/minimatch/raw/master/LICENSE' 40 } 41 ] 42} 43 44var fixture = new Tacks( 45 Dir({ 46 README: File( 47 'just an npm test\n' 48 ), 49 'package.json': File({ 50 name: 'npm-test-bundled-git', 51 scripts: { 52 test: 'node test.js' 53 }, 54 version: '1.2.5', 55 dependencies: { 56 glob: 'https://github.com/isaacs/node-glob.git#npm-test' 57 }, 58 bundledDependencies: [ 59 'glob' 60 ] 61 }) 62 }) 63) 64test('setup', function (t) { 65 setup() 66 t.done() 67}) 68test('bundled-git', function (t) { 69 common.npm(['install', '--global-style', fixturepath], {cwd: basepath}, installCheckAndTest) 70 function installCheckAndTest (err, code, stdout, stderr) { 71 if (err) throw err 72 t.is(code, 0, 'install went ok') 73 74 var actual = require(path.resolve(installedpath, 'node_modules/glob/node_modules/minimatch/package.json')) 75 Object.keys(minimatchExpected).forEach(function (key) { 76 t.isDeeply(actual[key], minimatchExpected[key], key + ' set to the right value') 77 }) 78 79 common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone) 80 } 81 function removeCheckAndDone (err, code, stdout, stderr) { 82 if (err) throw err 83 t.is(code, 0, 'remove went ok') 84 t.done() 85 } 86}) 87test('cleanup', function (t) { 88 cleanup() 89 t.done() 90}) 91function setup () { 92 cleanup() 93 fixture.create(fixturepath) 94 mkdirp.sync(modulepath) 95} 96function cleanup () { 97 fixture.remove(fixturepath) 98 rimraf.sync(basepath) 99} 100