(prettier: typeof import('prettier'), patterns: string[])
| 194 | } |
| 195 | |
| 196 | function write(prettier: typeof import('prettier'), patterns: string[]) { |
| 197 | if (patterns.length > 0) { |
| 198 | const [swcrcPatterns, regularPatterns] = patterns.reduce( |
| 199 | (result, pattern) => { |
| 200 | result[pattern.includes('.swcrc') ? 0 : 1].push(pattern); |
| 201 | return result; |
| 202 | }, |
| 203 | [[], []] as [swcrcPatterns: string[], regularPatterns: string[]] |
| 204 | ); |
| 205 | const prettierPath = getPrettierPath(); |
| 206 | const listDifferentArg = shouldUseListDifferent(prettier.version) |
| 207 | ? '--list-different ' |
| 208 | : ''; |
| 209 | |
| 210 | execSync( |
| 211 | `node "${prettierPath}" --write ${listDifferentArg}${regularPatterns.join( |
| 212 | ' ' |
| 213 | )}`, |
| 214 | { |
| 215 | stdio: [0, 1, 2], |
| 216 | windowsHide: true, |
| 217 | } |
| 218 | ); |
| 219 | |
| 220 | if (swcrcPatterns.length > 0) { |
| 221 | execSync( |
| 222 | `node "${prettierPath}" --write ${listDifferentArg}${swcrcPatterns.join( |
| 223 | ' ' |
| 224 | )} --parser json`, |
| 225 | { |
| 226 | stdio: [0, 1, 2], |
| 227 | windowsHide: true, |
| 228 | } |
| 229 | ); |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | async function check(patterns: string[]): Promise<string[]> { |
| 235 | if (patterns.length === 0) { |
no test coverage detected
searching dependent graphs…