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')
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',
24 test('setup', function (t) {
32 join('deps', 'foo', 'config', 'config.gypi')
35 test('follows npm package ignoring rules', function (t) {
36 var subject = new Packer({ path: pkg, type: 'Directory', isDirectory: true })
38 subject.on('entry', function (entry) {
39 t.equal(entry.type, 'File', 'only files in this package')
41 // include relative path in filename
42 var filename = entry._path.slice(entry.root._path.length + 1)
44 filenames.push(filename)
46 // need to do this so fstream doesn't explode when files are removed from
48 subject.on('end', function () {
49 // ensure we get *exactly* the results we expect by comparing in both
51 filenames.forEach(function (filename) {
53 included.indexOf(filename) > -1,
54 filename + ' is included'
57 included.forEach(function (filename) {
59 filenames.indexOf(filename) > -1,
60 filename + ' is not included'
67 test('cleanup', function (t) {
68 // rimraf.sync chokes here for some reason
69 rimraf(pkg, function () { t.end() })
76 join(pkg, 'package.json'),
77 JSON.stringify(json, null, 2)
91 join(pkg, '.npmignore'),
92 '.npmignore\ndummy\npackage.json'
100 var buildDir = join(pkg, 'build')
101 mkdirp.sync(buildDir)
103 join(buildDir, 'config.gypi'),
104 "i_wont_be_included_by_fstream='with any luck'"
107 var depscfg = join(pkg, 'deps', 'foo', 'config')
110 join(depscfg, 'config.gypi'),
111 "i_will_be_included_by_fstream='with any luck'"
115 join(buildDir, 'npm-debug.log'),
119 var gitDir = join(pkg, '.git')
122 join(gitDir, 'gitstub'),
123 "won't fool git, also won't be included by fstream"
126 var historyDir = join(pkg, 'node_modules/history')
127 mkdirp.sync(historyDir)
129 join(historyDir, 'README.md'),
130 "please don't include me"