@@ -111,3 +111,67 @@ t.test('packing a workspace root does not include children', async (t) => {
111
111
'workspaces/foo/package.json' ,
112
112
] )
113
113
} )
114
+
115
+ t . test ( '.gitignore is discarded if .npmignore exists outside of tree' , async ( t ) => {
116
+ const root = t . testdir ( {
117
+ 'package.json' : JSON . stringify ( {
118
+ name : 'workspace-root' ,
119
+ version : '1.0.0' ,
120
+ main : 'root.js' ,
121
+ workspaces : [ './workspaces/foo' ] ,
122
+ } ) ,
123
+ 'root.js' : `console.log('hello')` ,
124
+ '.gitignore' : 'dont-ignore-me' ,
125
+ '.npmignore' : 'only-ignore-me' ,
126
+ 'dont-ignore-me' : 'should not be ignored' ,
127
+ 'only-ignore-me' : 'should be ignored' ,
128
+ workspaces : {
129
+ '.gitignore' : 'dont-ignore-me-either' ,
130
+ '.npmignore' : 'ignore-me-also' ,
131
+ 'dont-ignore-me' : 'should not be ignored' ,
132
+ 'dont-ignore-me-either' : 'should not be ignored' ,
133
+ 'only-ignore-me' : 'should be ignored' ,
134
+ 'ignore-me-also' : 'should be ignored' ,
135
+ foo : {
136
+ 'package.json' : JSON . stringify ( {
137
+ name : 'workspace-child' ,
138
+ version : '1.0.0' ,
139
+ main : 'child.js' ,
140
+ } ) ,
141
+ 'child.js' : `console.log('hello')` ,
142
+ 'dont-ignore-me' : 'should not be ignored' ,
143
+ 'dont-ignore-me-either' : 'should not be ignored' ,
144
+ 'only-ignore-me' : 'should be ignored' ,
145
+ 'ignore-me-also' : 'should also be ignored' ,
146
+ } ,
147
+ } ,
148
+ } )
149
+
150
+ const workspacePath = path . join ( root , 'workspaces' , 'foo' )
151
+ // this simulates what it looks like when a user does i.e. npm pack -w ./workspaces/foo
152
+ const files = await packlist ( {
153
+ path : workspacePath ,
154
+ prefix : root ,
155
+ workspaces : [ workspacePath ] ,
156
+ } )
157
+ t . same ( files , [
158
+ 'dont-ignore-me' ,
159
+ 'dont-ignore-me-either' ,
160
+ 'child.js' ,
161
+ 'package.json' ,
162
+ ] )
163
+
164
+ // here we leave off workspaces to satisfy coverage
165
+ const secondFiles = await packlist ( {
166
+ path : workspacePath ,
167
+ prefix : root ,
168
+ } )
169
+ t . same ( secondFiles , [
170
+ 'dont-ignore-me' ,
171
+ 'dont-ignore-me-either' ,
172
+ 'ignore-me-also' ,
173
+ 'only-ignore-me' ,
174
+ 'child.js' ,
175
+ 'package.json' ,
176
+ ] )
177
+ } )
0 commit comments