@@ -179,3 +179,61 @@ t.test('global', async t => {
179
179
await npm . exec ( 'query' , [ '[name=lorem]' ] )
180
180
t . matchSnapshot ( joinedOutput ( ) , 'should return global package' )
181
181
} )
182
+
183
+ t . test ( 'package-lock-only' , t => {
184
+ t . test ( 'no package lock' , async t => {
185
+ const { npm } = await loadMockNpm ( t , {
186
+ config : {
187
+ 'package-lock-only' : true ,
188
+ } ,
189
+ prefixDir : {
190
+ 'package.json' : JSON . stringify ( {
191
+ name : 'project' ,
192
+ dependencies : {
193
+ a : '^1.0.0' ,
194
+ } ,
195
+ } ) ,
196
+ } ,
197
+ } )
198
+ await t . rejects ( npm . exec ( 'query' , [ ':root, :root > *' ] ) , { code : 'EUSAGE' } )
199
+ } )
200
+
201
+ t . test ( 'with package lock' , async t => {
202
+ const { npm, joinedOutput } = await loadMockNpm ( t , {
203
+ config : {
204
+ 'package-lock-only' : true ,
205
+ } ,
206
+ prefixDir : {
207
+ 'package.json' : JSON . stringify ( {
208
+ name : 'project' ,
209
+ dependencies : {
210
+ a : '^1.0.0' ,
211
+ } ,
212
+ } ) ,
213
+ 'package-lock.json' : JSON . stringify ( {
214
+ name : 'project' ,
215
+ lockfileVersion : 3 ,
216
+ requires : true ,
217
+ packages : {
218
+ '' : {
219
+ dependencies : {
220
+ a : '^1.0.0' ,
221
+ } ,
222
+ } ,
223
+ 'node_modules/a' : {
224
+ version : '1.2.3' ,
225
+ resolved : 'https://dummy.npmjs.org/a/-/a-1.2.3.tgz' ,
226
+ integrity : 'sha512-dummy' ,
227
+ engines : {
228
+ node : '>=14.17' ,
229
+ } ,
230
+ } ,
231
+ } ,
232
+ } ) ,
233
+ } ,
234
+ } )
235
+ await npm . exec ( 'query' , [ '*' ] )
236
+ t . matchSnapshot ( joinedOutput ( ) , 'should return valid response with only lock info' )
237
+ } )
238
+ t . end ( )
239
+ } )
0 commit comments