@@ -19,6 +19,7 @@ function main() {
1919 displayList ( 'THE FOLLOWING FILES WERE CHANGED:' , changedFiles ) ;
2020
2121 const changedPackages = identifyChangedPackages ( changedFiles ) ;
22+
2223 if ( changedPackages . length === 0 ) {
2324 console . log ( `No package-level changes. Using empty workspace arg to test all packages.` ) ;
2425 fs . writeFileSync ( tmpFilePath , '' ) ;
@@ -34,7 +35,17 @@ function main() {
3435 console . log ( `NO PACKAGES HAVE DEPENDENCIES ON CHANGED PACKAGES.\n` ) ;
3536 }
3637
37- const affectedPackages = [ ...( new Set ( [ ...changedPackages , ...dependentPackages ] ) . keys ( ) ) ] ;
38+ const undeletedChangedPackages = changedPackages . filter ( pkgLocation => {
39+ const packageName = pkgLocation . replace ( "packages" , "" ) . replace ( "/" , "" ) . replace ( "\\" , "" ) ;
40+ if ( fs . existsSync ( getPackageJsonFile ( packageName ) ) ) {
41+ return true ;
42+ } else {
43+ console . log ( `Removing package '${ packageName } ' from list of workspaces since it seems to have been deleted.` ) ;
44+ }
45+ } ) ;
46+
47+
48+ const affectedPackages = [ ...( new Set ( [ ...undeletedChangedPackages , ...dependentPackages ] ) . keys ( ) ) ] ;
3849 displayList ( 'BASED ON THE ABOVE, THE FOLLOWING PACKAGES ARE AFFECTED BY CHANGES, AND WILL REQUIRE TESTING:' , affectedPackages ) ;
3950
4051 const correspondingWorkspaceArgs = affectedPackages . map ( name => `--workspace ${ name } ` ) ;
@@ -100,8 +111,12 @@ function getAllPackageJsons() {
100111 return packagesDir . filter ( f => fs . statSync ( path . join ( pathToRoot , 'packages' , f ) ) . isDirectory ( ) ) . map ( getPackageJson ) ;
101112}
102113
114+ function getPackageJsonFile ( packageName ) {
115+ return path . join ( pathToRoot , 'packages' , packageName , 'package.json' ) ;
116+ }
117+
103118function getPackageJson ( packageName ) {
104- const packageJsonPath = path . join ( pathToRoot , 'packages' , packageName , 'package.json' ) ;
119+ const packageJsonPath = getPackageJsonFile ( packageName ) ;
105120 return JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf-8' ) ) ;
106121}
107122
0 commit comments