@@ -1407,14 +1407,16 @@ t.test('ls', (t) => {
1407
1407
} )
1408
1408
} )
1409
1409
1410
- t . test ( 'loading a tree containing workspaces' , ( t ) => {
1411
- npm . prefix = t . testdir ( {
1410
+ t . test ( 'loading a tree containing workspaces' , async ( t ) => {
1411
+ npm . localPrefix = npm . prefix = t . testdir ( {
1412
1412
'package.json' : JSON . stringify ( {
1413
- name : 'filter-by-child-of-missing-dep ' ,
1413
+ name : 'workspaces-tree ' ,
1414
1414
version : '1.0.0' ,
1415
1415
workspaces : [
1416
1416
'./a' ,
1417
1417
'./b' ,
1418
+ './d' ,
1419
+ './group/*' ,
1418
1420
] ,
1419
1421
} ) ,
1420
1422
node_modules : {
@@ -1426,13 +1428,29 @@ t.test('ls', (t) => {
1426
1428
version : '1.0.0' ,
1427
1429
} ) ,
1428
1430
} ,
1431
+ d : t . fixture ( 'symlink' , '../d' ) ,
1432
+ e : t . fixture ( 'symlink' , '../group/e' ) ,
1433
+ f : t . fixture ( 'symlink' , '../group/f' ) ,
1434
+ foo : {
1435
+ 'package.json' : JSON . stringify ( {
1436
+ name : 'foo' ,
1437
+ version : '1.1.1' ,
1438
+ dependencies : {
1439
+ bar : '^1.0.0' ,
1440
+ } ,
1441
+ } ) ,
1442
+ } ,
1443
+ bar : {
1444
+ 'package.json' : JSON . stringify ( { name : 'bar' , version : '1.0.0' } ) ,
1445
+ } ,
1429
1446
} ,
1430
1447
a : {
1431
1448
'package.json' : JSON . stringify ( {
1432
1449
name : 'a' ,
1433
1450
version : '1.0.0' ,
1434
1451
dependencies : {
1435
1452
c : '^1.0.0' ,
1453
+ d : '^1.0.0' ,
1436
1454
} ,
1437
1455
} ) ,
1438
1456
} ,
@@ -1442,18 +1460,104 @@ t.test('ls', (t) => {
1442
1460
version : '1.0.0' ,
1443
1461
} ) ,
1444
1462
} ,
1463
+ d : {
1464
+ 'package.json' : JSON . stringify ( {
1465
+ name : 'd' ,
1466
+ version : '1.0.0' ,
1467
+ dependencies : {
1468
+ foo : '^1.1.1' ,
1469
+ } ,
1470
+ } ) ,
1471
+ } ,
1472
+ group : {
1473
+ e : {
1474
+ 'package.json' : JSON . stringify ( {
1475
+ name : 'e' ,
1476
+ version : '1.0.0' ,
1477
+ } ) ,
1478
+ } ,
1479
+ f : {
1480
+ 'package.json' : JSON . stringify ( {
1481
+ name : 'f' ,
1482
+ version : '1.0.0' ,
1483
+ } ) ,
1484
+ } ,
1485
+ } ,
1445
1486
} )
1446
1487
1447
- ls . exec ( [ ] , ( err ) => {
1448
- t . error ( err , 'should NOT have ELSPROBLEMS error code' )
1449
- t . matchSnapshot ( redactCwd ( result ) , 'should list workspaces properly' )
1488
+ await new Promise ( ( res , rej ) => {
1489
+ config . all = false
1490
+ config . depth = 0
1491
+ npm . color = true
1492
+ ls . exec ( [ ] , ( err ) => {
1493
+ if ( err )
1494
+ rej ( err )
1495
+
1496
+ t . matchSnapshot ( redactCwd ( result ) ,
1497
+ 'should list workspaces properly with default configs' )
1498
+ config . all = true
1499
+ config . depth = Infinity
1500
+ npm . color = false
1501
+ res ( )
1502
+ } )
1503
+ } )
1504
+
1505
+ // --all
1506
+ await new Promise ( ( res , rej ) => {
1507
+ ls . exec ( [ ] , ( err ) => {
1508
+ if ( err )
1509
+ rej ( err )
1510
+
1511
+ t . matchSnapshot ( redactCwd ( result ) ,
1512
+ 'should list --all workspaces properly' )
1513
+ res ( )
1514
+ } )
1515
+ } )
1516
+
1517
+ // filter out a single workspace using args
1518
+ await new Promise ( ( res , rej ) => {
1519
+ ls . exec ( [ 'd' ] , ( err ) => {
1520
+ if ( err )
1521
+ rej ( err )
1450
1522
1451
- // should also be able to filter out one of the workspaces
1452
- ls . exec ( [ 'a' ] , ( err ) => {
1453
- t . error ( err , 'should NOT have ELSPROBLEMS error code when filter' )
1454
1523
t . matchSnapshot ( redactCwd ( result ) , 'should filter single workspace' )
1524
+ res ( )
1525
+ } )
1526
+ } )
1527
+
1528
+ // filter out a single workspace and its deps using workspaces filters
1529
+ await new Promise ( ( res , rej ) => {
1530
+ ls . execWorkspaces ( [ ] , [ 'a' ] , ( err ) => {
1531
+ if ( err )
1532
+ rej ( err )
1533
+
1534
+ t . matchSnapshot ( redactCwd ( result ) ,
1535
+ 'should filter using workspace config' )
1536
+ res ( )
1537
+ } )
1538
+ } )
1539
+
1540
+ // filter out a workspace by parent path
1541
+ await new Promise ( ( res , rej ) => {
1542
+ ls . execWorkspaces ( [ ] , [ './group' ] , ( err ) => {
1543
+ if ( err )
1544
+ rej ( err )
1545
+
1546
+ t . matchSnapshot ( redactCwd ( result ) ,
1547
+ 'should filter by parent folder workspace config' )
1548
+ res ( )
1549
+ } )
1550
+ } )
1551
+
1552
+ // filter by a dep within a workspaces sub tree
1553
+ await new Promise ( ( res , rej ) => {
1554
+ ls . execWorkspaces ( [ 'bar' ] , [ 'd' ] , ( err ) => {
1555
+ if ( err )
1556
+ rej ( err )
1455
1557
1456
- t . end ( )
1558
+ t . matchSnapshot ( redactCwd ( result ) ,
1559
+ 'should print all tree and filter by dep within only the ws subtree' )
1560
+ res ( )
1457
1561
} )
1458
1562
} )
1459
1563
} )
0 commit comments