@@ -237,9 +237,10 @@ loglevel = yolo
237
237
} )
238
238
logs . length = 0
239
239
await config . load ( )
240
- t . match ( logs , [ [ 'verbose' , 'config' , 'error loading user config' , {
241
- message : 'weird error' ,
242
- } ] ] )
240
+ t . match ( logs . find ( l => l [ 0 ] === 'verbose' ) ,
241
+ [ 'verbose' , 'config' , 'error loading user config' , {
242
+ message : 'weird error' ,
243
+ } ] )
243
244
logs . length = 0
244
245
} )
245
246
@@ -375,7 +376,7 @@ loglevel = yolo
375
376
376
377
// warn logs are emitted as a side effect of validate
377
378
config . validate ( )
378
- t . strictSame ( logs , [
379
+ t . strictSame ( logs . filter ( l => l [ 0 ] === 'warn' ) , [
379
380
[ 'warn' , 'invalid config' , 'registry="hello"' , 'set in command line options' ] ,
380
381
[ 'warn' , 'invalid config' , 'Must be' , 'full url with "http://"' ] ,
381
382
[ 'warn' , 'invalid config' , 'proxy="hello"' , 'set in command line options' ] ,
@@ -392,8 +393,7 @@ loglevel = yolo
392
393
[ 'warn' , 'invalid config' , 'prefix=true' , 'set in command line options' ] ,
393
394
[ 'warn' , 'invalid config' , 'Must be' , 'valid filesystem path' ] ,
394
395
[ 'warn' , 'config' , 'also' , 'Please use --include=dev instead.' ] ,
395
- [ 'warn' , 'invalid config' , 'loglevel="yolo"' ,
396
- `set in ${ resolve ( path , 'project/.npmrc' ) } ` ] ,
396
+ [ 'warn' , 'invalid config' , 'loglevel="yolo"' , `set in ${ resolve ( path , 'project/.npmrc' ) } ` ] ,
397
397
[ 'warn' , 'invalid config' , 'Must be one of:' ,
398
398
[ 'silent' , 'error' , 'warn' , 'notice' , 'http' , 'info' , 'verbose' , 'silly' ] . join ( ', ' ) ,
399
399
] ,
@@ -570,7 +570,7 @@ loglevel = yolo
570
570
all : config . get ( 'all' ) ,
571
571
} )
572
572
573
- t . strictSame ( logs , [
573
+ t . strictSame ( logs . filter ( l => l [ 0 ] === 'warn' ) , [
574
574
[ 'warn' , 'invalid config' , 'registry="hello"' , 'set in command line options' ] ,
575
575
[ 'warn' , 'invalid config' , 'Must be' , 'full url with "http://"' ] ,
576
576
[ 'warn' , 'invalid config' , 'proxy="hello"' , 'set in command line options' ] ,
@@ -1183,8 +1183,9 @@ t.test('workspaces', async (t) => {
1183
1183
await config . load ( )
1184
1184
t . equal ( config . localPrefix , path , 'localPrefix is the root' )
1185
1185
t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'one' ) ] , 'set the workspace' )
1186
- t . equal ( logs . length , 1 , 'got one log message' )
1187
- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1186
+ const info = logs . filter ( l => l [ 0 ] === 'info' )
1187
+ t . equal ( info . length , 1 , 'got one log message' )
1188
+ t . match ( info [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1188
1189
} )
1189
1190
1190
1191
t . test ( 'finds other workspace parent' , async ( t ) => {
@@ -1204,8 +1205,9 @@ t.test('workspaces', async (t) => {
1204
1205
await config . load ( )
1205
1206
t . equal ( config . localPrefix , path , 'localPrefix is the root' )
1206
1207
t . same ( config . get ( 'workspace' ) , [ '../two' ] , 'kept the specified workspace' )
1207
- t . equal ( logs . length , 1 , 'got one log message' )
1208
- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1208
+ const info = logs . filter ( l => l [ 0 ] === 'info' )
1209
+ t . equal ( info . length , 1 , 'got one log message' )
1210
+ t . match ( info [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1209
1211
} )
1210
1212
1211
1213
t . test ( 'warns when workspace has .npmrc' , async ( t ) => {
@@ -1225,9 +1227,10 @@ t.test('workspaces', async (t) => {
1225
1227
await config . load ( )
1226
1228
t . equal ( config . localPrefix , path , 'localPrefix is the root' )
1227
1229
t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'three' ) ] , 'kept the workspace' )
1228
- t . equal ( logs . length , 2 , 'got two log messages' )
1229
- t . match ( logs [ 0 ] , [ 'warn' , / ^ i g n o r i n g w o r k s p a c e c o n f i g / ] , 'warned about ignored config' )
1230
- t . match ( logs [ 1 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1230
+ const filtered = logs . filter ( l => l [ 0 ] === 'info' || l [ 0 ] === 'warn' )
1231
+ t . equal ( filtered . length , 2 , 'got two log messages' )
1232
+ t . match ( filtered [ 0 ] , [ 'warn' , / ^ i g n o r i n g w o r k s p a c e c o n f i g / ] , 'warned about ignored config' )
1233
+ t . match ( filtered [ 1 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1231
1234
} )
1232
1235
1233
1236
t . test ( 'prefix skips auto detect' , async ( t ) => {
@@ -1247,7 +1250,8 @@ t.test('workspaces', async (t) => {
1247
1250
await config . load ( )
1248
1251
t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1249
1252
t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1250
- t . equal ( logs . length , 0 , 'got no log messages' )
1253
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1254
+ t . equal ( filtered . length , 0 , 'got no log messages' )
1251
1255
} )
1252
1256
1253
1257
t . test ( 'no-workspaces skips auto detect' , async ( t ) => {
@@ -1267,7 +1271,8 @@ t.test('workspaces', async (t) => {
1267
1271
await config . load ( )
1268
1272
t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1269
1273
t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1270
- t . equal ( logs . length , 0 , 'got no log messages' )
1274
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1275
+ t . equal ( filtered . length , 0 , 'got no log messages' )
1271
1276
} )
1272
1277
1273
1278
t . test ( 'global skips auto detect' , async ( t ) => {
@@ -1287,7 +1292,8 @@ t.test('workspaces', async (t) => {
1287
1292
await config . load ( )
1288
1293
t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1289
1294
t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1290
- t . equal ( logs . length , 0 , 'got no log messages' )
1295
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1296
+ t . equal ( filtered . length , 0 , 'got no log messages' )
1291
1297
} )
1292
1298
1293
1299
t . test ( 'location=global skips auto detect' , async ( t ) => {
@@ -1307,7 +1313,8 @@ t.test('workspaces', async (t) => {
1307
1313
await config . load ( )
1308
1314
t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1309
1315
t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1310
- t . equal ( logs . length , 0 , 'got no log messages' )
1316
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1317
+ t . equal ( filtered . length , 0 , 'got no log messages' )
1311
1318
} )
1312
1319
1313
1320
t . test ( 'excludeNpmCwd skips auto detect' , async ( t ) => {
@@ -1328,7 +1335,8 @@ t.test('workspaces', async (t) => {
1328
1335
await config . load ( )
1329
1336
t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1330
1337
t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1331
- t . equal ( logs . length , 0 , 'got no log messages' )
1338
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1339
+ t . equal ( filtered . length , 0 , 'got no log messages' )
1332
1340
} )
1333
1341
1334
1342
t . test ( 'does not error for invalid package.json' , async ( t ) => {
@@ -1354,8 +1362,9 @@ t.test('workspaces', async (t) => {
1354
1362
await config . load ( )
1355
1363
t . equal ( config . localPrefix , path , 'localPrefix is the root' )
1356
1364
t . same ( config . get ( 'workspace' ) , [ join ( path , 'workspaces' , 'one' ) ] , 'set the workspace' )
1357
- t . equal ( logs . length , 1 , 'got one log message' )
1358
- t . match ( logs [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1365
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1366
+ t . equal ( filtered . length , 1 , 'got one log message' )
1367
+ t . match ( filtered [ 0 ] , [ 'info' , / ^ f o u n d w o r k s p a c e r o o t a t / ] , 'logged info about workspace root' )
1359
1368
} )
1360
1369
} )
1361
1370
@@ -1474,7 +1483,8 @@ t.test('catch project config prefix error', async t => {
1474
1483
logs . length = 0
1475
1484
// config.load() triggers the error to be logged
1476
1485
await config . load ( )
1477
- t . match ( logs , [ [
1486
+ const filtered = logs . filter ( l => l [ 0 ] !== 'silly' )
1487
+ t . match ( filtered , [ [
1478
1488
'error' , 'config' , `prefix cannot be changed from project config: ${ path } ` ,
1479
1489
] ] , 'Expected error logged' )
1480
1490
} )
0 commit comments