diff --git a/packages/workspace/src/command-line/format.ts b/packages/workspace/src/command-line/format.ts index 720ac64083e530..b031e924355169 100644 --- a/packages/workspace/src/command-line/format.ts +++ b/packages/workspace/src/command-line/format.ts @@ -96,9 +96,14 @@ function printError(command: string, e: any) { function write(patterns: string[]) { if (patterns.length > 0) { - execSync(`node "${prettierPath()}" --write ${patterns.join(' ')}`, { - stdio: [0, 1, 2] - }); + execSync( + `node "${prettierPath()}" --write ${patterns + .map(pattern => fileExists(pattern) ? `'${pattern}'` : pattern) + .join(' ')}`, + { + stdio: [0, 1, 2] + } + ); } } @@ -106,7 +111,9 @@ function check(patterns: string[]) { if (patterns.length > 0) { try { execSync( - `node "${prettierPath()}" --list-different ${patterns.join(' ')}`, + `node "${prettierPath()}" --list-different ${patterns + .map(pattern => fileExists(pattern) ? `'${pattern}'` : pattern) + .join(' ')}`, { stdio: [0, 1, 2] }