File tree Expand file tree Collapse file tree 2 files changed +12
-26
lines changed
Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @preconstruct/cli " : patch
3+ ---
4+
5+ Exclude package directories without package.jsons rather than prompting to delete them, this aligns with the behaviour of package managers.
Original file line number Diff line number Diff line change @@ -94,46 +94,27 @@ export class Project extends Item {
9494 expandDirectories : false
9595 } ) ;
9696
97- let dirsWithoutPkgJson : string [ ] = [ ] ;
98- let lastErr ;
97+ let packages : Package [ ] = [ ] ;
9998
100- let packages = await Promise . all (
99+ await Promise . all (
101100 filenames . map ( async x => {
102101 try {
103- return await Package . create ( x , this ) ;
102+ packages . push ( await Package . create ( x , this ) ) ;
104103 } catch ( err ) {
105104 if (
106105 err . code === "ENOENT" &&
107106 err . path === nodePath . join ( x , "package.json" )
108107 ) {
109- lastErr = err ;
110- dirsWithoutPkgJson . push ( x ) ;
111- return ( undefined as any ) as Package ;
108+ return ;
112109 }
113110 throw err ;
114111 }
115112 } )
116113 ) ;
117- if ( dirsWithoutPkgJson . length ) {
118- error (
119- "there are some package directories that do not have package.jsons\nthis is often caused by switching branches.\n\n" +
120- dirsWithoutPkgJson . join ( "\n" ) +
121- "\n"
122- ) ;
123- if (
124- ! ( await promptConfirm (
125- "would you like preconstruct to delete these directories automatically?"
126- ) )
127- ) {
128- throw lastErr ;
129- }
130- await Promise . all ( dirsWithoutPkgJson . map ( dir => fs . remove ( dir ) ) ) ;
131- return this . _packages ( ) ;
132- }
133114
134- const errored = ( await allSettled (
135- packages . map ( pkg => validateIncludedFiles ( pkg ) )
136- ) ) . find ( result => result . status === "rejected" ) ;
115+ const errored = (
116+ await allSettled ( packages . map ( pkg => validateIncludedFiles ( pkg ) ) )
117+ ) . find ( result => result . status === "rejected" ) ;
137118
138119 if ( errored ) {
139120 // TS can't refine type based on .find predicate
You can’t perform that action at this time.
0 commit comments