diff --git a/package-lock.json b/package-lock.json index d1a76da..e48cb08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polyapi", - "version": "0.23.24", + "version": "0.23.26", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polyapi", - "version": "0.23.24", + "version": "0.23.26", "license": "MIT", "dependencies": { "@guanghechen/helper-string": "4.7.1", diff --git a/package.json b/package.json index bb6c71f..537f65d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polyapi", - "version": "0.23.25", + "version": "0.23.26", "description": "Poly is a CLI tool to help create and manage your Poly definitions.", "license": "MIT", "repository": { diff --git a/src/deployables.ts b/src/deployables.ts index a4b72b5..419cfa1 100644 --- a/src/deployables.ts +++ b/src/deployables.ts @@ -170,26 +170,33 @@ export const getAllDeployableFilesWindows = ({ excludeDirs, }: PolyDeployConfig): string[] => { // To get the equivalent of grep in Windows we use a combination of `dir` and `findstr` - const includePattern = - includeFilesOrExtensions.length > 0 - ? includeFilesOrExtensions - .map((f) => (f.includes('.') ? f : `*.${f}`)) - .join(' ') - : '*'; - const excludePattern = excludeDirs.length > 0 ? excludeDirs.join('|') : ''; + const excludePattern = excludeDirs.length > 0 + ? excludeDirs + .map((f) => `\\${f}`) + .join(' ') : ''; const pattern = typeNames.length > 0 - ? typeNames.map((name) => `polyConfig: ${name}`).join('|') + ? typeNames.map((name) => `\\`).join(' ') : 'polyConfig'; + // Using two regular quotes or two smart quotes throws "The syntax of the command is incorrect". + // For some reason, starting with a regular quote and leaving the end without a quote works. const excludeCommand = excludePattern - ? ` | findstr /V /I "${excludePattern}"` + ? ` | findstr /V /I "${excludePattern}` : ''; - const searchCommand = ` | findstr /M /I /F:/ /C:"${pattern}"`; + const searchCommand = ` | findstr /M /I /F:/ ${pattern}`; let result: string[] = []; for (const dir of includeDirs) { - const dirCommand = `dir /S /P /B ${includePattern} ${dir}`; + const includePattern = + dir === '.' + ? includeFilesOrExtensions + .map((f) => (f.includes('.') ? f : `*.${f}`)) + .join(' ') + : includeFilesOrExtensions + .map((f) => (f.includes('.') ? f : `${dir}*.${f}`)) + .join(' '); + const dirCommand = `dir ${includePattern} /S /P /B`; const fullCommand = `${dirCommand}${excludeCommand}${searchCommand}`; try { const output = shell.exec(fullCommand).toString('utf8'); @@ -230,13 +237,13 @@ export const getAllDeployableFilesLinux = ({ export const getAllDeployableFiles = ( config: Partial = {}, ): string[] => { - config.typeNames = config.typeNames = DeployableTypeEntries.map((p) => p[0]); - config.includeDirs = config.includeDirs = ['.']; - config.includeFilesOrExtensions = config.includeFilesOrExtensions = [ + config.typeNames = config.typeNames || DeployableTypeEntries.map((p) => p[0]); + config.includeDirs = config.includeDirs || ['.']; + config.includeFilesOrExtensions = config.includeFilesOrExtensions || [ 'ts', 'js', ]; - config.excludeDirs = config.excludeDirs = [ + config.excludeDirs = config.excludeDirs || [ 'node_modules', 'dist', 'build',