Skip to content

Commit

Permalink
Avoiding ignoring files as we go, for now, as it can be problematic i…
Browse files Browse the repository at this point in the history
…n some cases
  • Loading branch information
fabiospampinato committed Apr 19, 2024
1 parent 8b539fe commit 7375b81
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 39 deletions.
36 changes: 7 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"specialist": "^1.4.0",
"tiny-editorconfig": "^1.0.0",
"tiny-jsonc": "^1.0.1",
"tiny-readdir-glob-gitignore": "^1.0.2",
"tiny-readdir-glob": "^1.22.24",
"tiny-spinner": "^2.0.3",
"worktank": "^2.6.1",
"zeptomatch": "^2.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ async function runGlobs(options: Options, pluginsOptions: PluginsOptions): Promi

const rootPath = process.cwd();
const projectPath = getProjectPath(rootPath);
const ignoreFiles = options.ignorePath ? [] : [".gitignore", ".prettierignore"];
const [filesPaths, filesNames, filesNamesToPaths, filesFoundPaths, foldersFoundPaths] = await getTargetsPaths(rootPath, options.globs, ignoreFiles, options.withNodeModules); // prettier-ignore
const [filesPaths, filesNames, filesNamesToPaths, filesFoundPaths, foldersFoundPaths] = await getTargetsPaths(rootPath, options.globs, options.withNodeModules); // prettier-ignore
const filesPathsTargets = filesPaths.filter(negate(isBinaryPath)).sort();
const [foldersPathsTargets, foldersExtraPaths] = getExpandedFoldersPaths(foldersFoundPaths, projectPath);
const filesExtraPaths = await getFoldersChildrenPaths([rootPath, ...foldersExtraPaths]);
Expand Down Expand Up @@ -105,7 +104,7 @@ async function runGlobs(options: Options, pluginsOptions: PluginsOptions): Promi
filesPathsTargets.map(async (filePath) => {
const isIgnored = () => (ignoreManual ? ignoreManual(filePath) : getIgnoreResolved(filePath, ignoreNames));
const isCacheable = () => cache?.has(filePath, isIgnored);
const ignored = !ignoreFiles.length && (cache ? !(await isCacheable()) : await isIgnored());
const ignored = cache ? !(await isCacheable()) : await isIgnored();
if (ignored) return;
const getFormatOptions = async (): Promise<FormatOptions> => {
const editorConfig = options.editorConfig ? getEditorConfigFormatOptions(await getEditorConfigResolved(filePath, editorConfigNames)) : {};
Expand Down
9 changes: 3 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { text as stream2text } from "node:stream/consumers";
import url from "node:url";
import resolveTimeout from "promise-resolve-timeout";
import { exit } from "specialist";
import readdir from "tiny-readdir-glob-gitignore";
import readdir from "tiny-readdir-glob";
import zeptomatchEscape from "zeptomatch-escape";
import zeptomatchIsStatic from "zeptomatch-is-static";
import type { ContextOptions, FormatOptions, FunctionMaybe, Key, LogLevel, Options, PrettierConfigWithOverrides, PrettierPlugin } from "./types.js";
Expand Down Expand Up @@ -87,13 +87,11 @@ async function getFoldersChildrenPaths(foldersPaths: string[]): Promise<string[]
return childrenPaths;
}

function getGlobPaths(rootPath: string, globs: string[], ignoreFiles: string[], withNodeModules: boolean) {
function getGlobPaths(rootPath: string, globs: string[], withNodeModules: boolean) {
return readdir(globs, {
cwd: rootPath,
followSymlinks: false,
ignore: `**/{.git,.sl,.svn,.hg,.DS_Store,Thumbs.db${withNodeModules ? "" : ",node_modules"}}`,
ignoreFiles,
ignoreFilesFindAbove: false,
});
}

Expand Down Expand Up @@ -186,7 +184,6 @@ const getStdin = once(async (): Promise<string | undefined> => {
async function getTargetsPaths(
rootPath: string,
globs: string[],
ignoreFiles: string[],
withNodeModules: boolean,
): Promise<[string[], string[], Record<string, string[]>, string[], string[]]> {
const targetFiles: string[] = [];
Expand All @@ -207,7 +204,7 @@ async function getTargetsPaths(
}
}

const result = await getGlobPaths(rootPath, targetGlobs, ignoreFiles, withNodeModules);
const result = await getGlobPaths(rootPath, targetGlobs, withNodeModules);
const filesPaths = [...targetFiles, ...result.files];
const filesNames = [...targetFilesNames, ...result.filesFoundNames];
const filesNamesToPaths = result.filesFoundNamesToPaths;
Expand Down

0 comments on commit 7375b81

Please sign in to comment.