Skip to content

Commit a3e797b

Browse files
authored
Ported test suite: infer-plugins-ext-dir (#34)
- Relative plugins in nested configurations are resolved from the CWD at the moment, instead than from the folder the config file was found in, it should be fixed.
1 parent b9e0cb9 commit a3e797b

31 files changed

Lines changed: 444 additions & 97 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Thumbs.db
1212

1313
/dist
1414
/node_modules
15+
/test/__fixtures__/.temp-*

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"find-up-json": "^2.0.5",
4141
"function-once": "^3.0.1",
4242
"import-meta-resolve": "^4.1.0",
43-
"is-binary-path": "^3.0.0",
43+
"is-binary-path": "^2.0.0",
4444
"js-yaml": "^4.1.0",
4545
"json-sorted-stringify": "^1.0.1",
4646
"json5": "^2.2.3",
@@ -54,7 +54,7 @@
5454
"tiny-readdir": "^2.7.4",
5555
"tiny-readdir-glob": "^1.23.2",
5656
"tiny-spinner": "^2.0.5",
57-
"worktank": "^2.7.3",
57+
"worktank": "^3.0.2",
5858
"zeptomatch": "^2.0.1",
5959
"zeptomatch-escape": "^1.0.1",
6060
"zeptomatch-is-static": "^1.0.1"

src/prettier_parallel.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import os from "node:os";
2+
import process from "node:process";
23
import WorkTank from "worktank";
34
import { resolve } from "./utils.js";
45
import type { Options, Prettier } from "./types.js";
56

67
function makeParallel(options: Options): Prettier {
78
const pool = new WorkTank<Prettier>({
8-
name: "prettier",
9-
size: options.parallelWorkers || Math.max(1, os.cpus().length - 1),
10-
methods: new URL("./prettier_serial.js", import.meta.url),
11-
warmup: true,
9+
pool: {
10+
name: "prettier",
11+
size: options.parallelWorkers || Math.max(1, os.cpus().length - 1),
12+
},
13+
worker: {
14+
autoInstantiate: true,
15+
env: process.env,
16+
methods: new URL("./prettier_serial.js", import.meta.url),
17+
},
1218
});
1319

1420
return {

src/utils.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,15 @@ async function getTargetsPaths(
277277
}
278278

279279
const filesExplicitPaths = targetFiles;
280-
const filesFoundPaths = globResult.filesFound;
281-
const foldersFoundPaths = [rootPath, ...globResult.directoriesFound];
280+
281+
const globFilesFoundPaths = globResult.filesFound;
282+
const directoryFilesFoundPaths = directoriesResultsFiles.flat();
283+
const filesFoundPaths = [...globFilesFoundPaths, ...directoryFilesFoundPaths];
284+
285+
const globFoldersFoundPaths = globResult.directoriesFound;
286+
const directoryFoldersFoundPaths = directoriesResults.flatMap((result) => result.directories);
287+
const foldersFoundPaths = [rootPath, ...globFoldersFoundPaths, ...directoryFoldersFoundPaths];
288+
282289
return [filesPaths, filesNames, filesNamesToPaths, filesExplicitPaths, filesFoundPaths, foldersFoundPaths];
283290
}
284291

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
overrides: [
3+
{
4+
files: ["dir/*.foo"],
5+
options: {
6+
plugins: ["../plugin-extensions/plugin.cjs"]
7+
}
8+
},
9+
]
10+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.foo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.foo
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
plugins: ["../plugin-extensions/plugin.cjs"],
3+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
contents

0 commit comments

Comments
 (0)