MCPcopy
hub / github.com/nrwl/nx / write

Function write

packages/nx/src/command-line/format/format.ts:196–232  ·  view source on GitHub ↗
(prettier: typeof import('prettier'), patterns: string[])

Source from the content-addressed store, hash-verified

194}
195
196function 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
234async function check(patterns: string[]): Promise<string[]> {
235 if (patterns.length === 0) {

Callers 1

formatFunction · 0.70

Calls 3

getPrettierPathFunction · 0.85
shouldUseListDifferentFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…