Skip to content

Commit

Permalink
fix(nx): wrap files inputted to prettier in quotes
Browse files Browse the repository at this point in the history
Files that contained parentheses caused 'yarn format' to fail unless the files passed to the
prettier cli are wrapped in quotes

fix nrwl#1473
  • Loading branch information
ZachJW34 committed Jun 12, 2019
1 parent 7ddc75f commit 094c899
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/workspace/src/command-line/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,24 @@ 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]
}
);
}
}

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]
}
Expand Down

0 comments on commit 094c899

Please sign in to comment.