@@ -9,8 +9,6 @@ var Packer = require('..')
9
9
10
10
var pkg = join ( __dirname , 'test-package' )
11
11
12
- var gitDir = join ( pkg , '.git' )
13
-
14
12
var elfJS = function ( ) { /*
15
13
module.exports = function () {
16
14
console.log("i'm a elf")
@@ -35,26 +33,36 @@ var included = [
35
33
36
34
test ( 'follows npm package ignoring rules' , function ( t ) {
37
35
var subject = new Packer ( { path : pkg , type : 'Directory' , isDirectory : true } )
36
+ var seen = { }
38
37
subject . on ( 'entry' , function ( entry ) {
39
38
t . equal ( entry . type , 'File' , 'only files in this package' )
40
39
var filename = entry . basename
41
40
t . ok (
42
41
included . indexOf ( filename ) > - 1 ,
43
42
filename + ' is included'
44
43
)
44
+ seen [ filename ] = true
45
45
} )
46
46
// need to do this so fstream doesn't explode when files are removed from
47
47
// under it
48
- subject . on ( 'end' , function ( ) { t . end ( ) } )
48
+ subject . on ( 'end' , function ( ) {
49
+ included . forEach ( function ( filename ) {
50
+ t . ok (
51
+ seen [ filename ] ,
52
+ filename + ' was not excluded'
53
+ )
54
+ } )
55
+ t . end ( )
56
+ } )
49
57
} )
50
58
51
59
test ( 'cleanup' , function ( t ) {
52
- cleanup ( )
53
- t . end ( )
60
+ // rimraf.sync chokes here for some reason
61
+ rimraf ( pkg , function ( ) { t . end ( ) } )
54
62
} )
55
63
56
64
function setup ( ) {
57
- cleanup ( )
65
+ rimraf . sync ( pkg )
58
66
mkdirp . sync ( pkg )
59
67
fs . writeFileSync (
60
68
join ( pkg , 'package.json' ) ,
@@ -71,25 +79,39 @@ function setup () {
71
79
'packaged=false'
72
80
)
73
81
74
- var build = join ( pkg , 'build' )
75
- mkdirp . sync ( build )
76
82
fs . writeFileSync (
77
- join ( build , 'config.gypi' ) ,
83
+ join ( pkg , '.npmignore' ) ,
84
+ '.npmignore\ndummy\npackage.json'
85
+ )
86
+
87
+ fs . writeFileSync (
88
+ join ( pkg , 'dummy' ) ,
89
+ 'foo'
90
+ )
91
+
92
+ var buildDir = join ( pkg , 'build' )
93
+ mkdirp . sync ( buildDir )
94
+ fs . writeFileSync (
95
+ join ( buildDir , 'config.gypi' ) ,
78
96
"i_wont_be_included_by_fstream='with any luck'"
79
97
)
80
98
81
99
fs . writeFileSync (
82
- join ( build , 'npm-debug.log' ) ,
100
+ join ( buildDir , 'npm-debug.log' ) ,
83
101
'0 lol\n'
84
102
)
85
103
104
+ var gitDir = join ( pkg , '.git' )
86
105
mkdirp . sync ( gitDir )
87
106
fs . writeFileSync (
88
107
join ( gitDir , 'gitstub' ) ,
89
108
"won't fool git, also won't be included by fstream"
90
109
)
91
- }
92
110
93
- function cleanup ( ) {
94
- rimraf . sync ( pkg )
111
+ var historyDir = join ( pkg , 'node_modules/history' )
112
+ mkdirp . sync ( historyDir )
113
+ fs . writeFileSync (
114
+ join ( historyDir , 'README.md' ) ,
115
+ "please don't include me"
116
+ )
95
117
}
0 commit comments