Skip to content

Commit eebcdbf

Browse files
Changed command structure to fix windows glide bug (#15)
* Changed command structure to fix windows glide bug * Added comment to explain strange syntax * Allowed directories to be specified in the command * Updated excludeCommand quotations and comment * Updated version * Added package-lock.json
1 parent c03eed7 commit eebcdbf

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyapi",
3-
"version": "0.23.25",
3+
"version": "0.23.26",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

src/deployables.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = ({
230237
export 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

Comments
 (0)