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 = common.pkg 8var fixturepath = path.resolve(basepath, 'npm-test-ignore-nested-nm') 9var modulepath = path.resolve(basepath, 'node_modules') 10var installedpath = path.resolve(modulepath, 'npm-test-ignore-nested-nm') 11var fs = require('graceful-fs') 12var Tacks = require('tacks') 13var File = Tacks.File 14var Dir = Tacks.Dir 15 16var fileData = 'I WILL NOT BE IGNORED!\n' 17var fixture = new Tacks( 18 Dir({ 19 lib: Dir({ 20 node_modules: Dir({ 21 foo: File(fileData) 22 }) 23 }), 24 'package.json': File({ 25 name: 'npm-test-ignore-nested-nm', 26 version: '1.2.5' 27 }) 28 }) 29) 30test('setup', function (t) { 31 setup() 32 t.done() 33}) 34test('ignore-nested-nm', function (t) { 35 common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest) 36 function installCheckAndTest (err, code, stdout, stderr) { 37 if (err) throw err 38 t.is(code, 0, 'install went ok') 39 var foopath = path.resolve(installedpath, 'lib/node_modules/foo') 40 fs.readFile(foopath, function (err, data) { 41 t.ifError(err, 'file read successfully') 42 t.equal(data.toString(), fileData) 43 common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone) 44 }) 45 } 46 function removeCheckAndDone (err, code, stdout, stderr) { 47 if (err) throw err 48 t.is(code, 0, 'remove went ok') 49 t.done() 50 } 51}) 52test('cleanup', function (t) { 53 cleanup() 54 t.done() 55}) 56function setup () { 57 cleanup() 58 fixture.create(fixturepath) 59 mkdirp.sync(modulepath) 60} 61function cleanup () { 62 fixture.remove(fixturepath) 63 rimraf.sync(basepath) 64} 65