@@ -170,26 +170,33 @@ export const getAllDeployableFilesWindows = ({
170170 excludeDirs,
171171} : PolyDeployConfig ) : string [ ] => {
172172 // To get the equivalent of grep in Windows we use a combination of `dir` and `findstr`
173- const includePattern =
174- includeFilesOrExtensions . length > 0
175- ? includeFilesOrExtensions
176- . map ( ( f ) => ( f . includes ( '.' ) ? f : `*.${ f } ` ) )
177- . join ( ' ' )
178- : '*' ;
179- const excludePattern = excludeDirs . length > 0 ? excludeDirs . join ( '|' ) : '' ;
173+ const excludePattern = excludeDirs . length > 0
174+ ? excludeDirs
175+ . map ( ( f ) => `\\${ f } ` )
176+ . join ( ' ' ) : '' ;
180177 const pattern =
181178 typeNames . length > 0
182- ? typeNames . map ( ( name ) => `polyConfig: ${ name } ` ) . join ( '| ' )
179+ ? typeNames . map ( ( name ) => `\\< polyConfig: ${ name } \\> ` ) . join ( ' ' )
183180 : 'polyConfig' ;
184181
182+ // Using two regular quotes or two smart quotes throws "The syntax of the command is incorrect".
183+ // For some reason, starting with a regular quote and leaving the end without a quote works.
185184 const excludeCommand = excludePattern
186- ? ` | findstr /V /I "${ excludePattern } " `
185+ ? ` | findstr /V /I "${ excludePattern } `
187186 : '' ;
188- const searchCommand = ` | findstr /M /I /F:/ /C:" ${ pattern } " ` ;
187+ const searchCommand = ` | findstr /M /I /F:/ ${ pattern } ` ;
189188
190189 let result : string [ ] = [ ] ;
191190 for ( const dir of includeDirs ) {
192- const dirCommand = `dir /S /P /B ${ includePattern } ${ dir } ` ;
191+ const includePattern =
192+ dir === '.'
193+ ? includeFilesOrExtensions
194+ . map ( ( f ) => ( f . includes ( '.' ) ? f : `*.${ f } ` ) )
195+ . join ( ' ' )
196+ : includeFilesOrExtensions
197+ . map ( ( f ) => ( f . includes ( '.' ) ? f : `${ dir } *.${ f } ` ) )
198+ . join ( ' ' ) ;
199+ const dirCommand = `dir ${ includePattern } /S /P /B` ;
193200 const fullCommand = `${ dirCommand } ${ excludeCommand } ${ searchCommand } ` ;
194201 try {
195202 const output = shell . exec ( fullCommand ) . toString ( 'utf8' ) ;
@@ -230,13 +237,13 @@ export const getAllDeployableFilesLinux = ({
230237export const getAllDeployableFiles = (
231238 config : Partial < PolyDeployConfig > = { } ,
232239) : string [ ] => {
233- config . typeNames = config . typeNames = DeployableTypeEntries . map ( ( p ) => p [ 0 ] ) ;
234- config . includeDirs = config . includeDirs = [ '.' ] ;
235- config . includeFilesOrExtensions = config . includeFilesOrExtensions = [
240+ config . typeNames = config . typeNames || DeployableTypeEntries . map ( ( p ) => p [ 0 ] ) ;
241+ config . includeDirs = config . includeDirs || [ '.' ] ;
242+ config . includeFilesOrExtensions = config . includeFilesOrExtensions || [
236243 'ts' ,
237244 'js' ,
238245 ] ;
239- config . excludeDirs = config . excludeDirs = [
246+ config . excludeDirs = config . excludeDirs || [
240247 'node_modules' ,
241248 'dist' ,
242249 'build' ,
0 commit comments