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