1 var fs = require('graceful-fs')
2 var join = require('path').join
4 var mkdirp = require('mkdirp')
5 var rimraf = require('rimraf')
6 var test = require('tap').test
8 var Packer = require('..')
10 var pkg = join(__dirname, 'test-package-scoped')
12 var elfJS = function () {/*
13 module.exports = function () {
14 console.log("i'm a elf")
16 */}.toString().split('\n').slice(1, -1).join()
19 'name': 'test-package-scoped',
22 'bundledDependencies': [
27 test('setup', function (t) {
35 join('node_modules', '@npmwombat', 'scoped', 'index.js')
38 test('includes bundledDependencies', function (t) {
39 var subject = new Packer({ path: pkg, type: 'Directory', isDirectory: true })
41 subject.on('entry', function (entry) {
42 t.equal(entry.type, 'File', 'only files in this package')
44 // include relative path in filename
45 var filename = entry._path.slice(entry.root._path.length + 1)
47 filenames.push(filename)
49 // need to do this so fstream doesn't explode when files are removed from
51 subject.on('end', function () {
52 // ensure we get *exactly* the results we expect by comparing in both
54 filenames.forEach(function (filename) {
56 included.indexOf(filename) > -1,
57 filename + ' is included'
60 included.forEach(function (filename) {
62 filenames.indexOf(filename) > -1,
63 filename + ' is not included'
70 test('cleanup', function (t) {
71 // rimraf.sync chokes here for some reason
72 rimraf(pkg, function () { t.end() })
79 join(pkg, 'package.json'),
80 JSON.stringify(json, null, 2)
88 var scopedDir = join(pkg, 'node_modules', '@npmwombat', 'scoped')
89 mkdirp.sync(scopedDir)
91 join(scopedDir, 'index.js'),
92 "console.log('hello wombat')"