From 1e1b5a6f09c71685d58aef400ac6254af892d669 Mon Sep 17 00:00:00 2001 From: stefanprobst Date: Sat, 25 Jun 2022 06:22:06 +0200 Subject: [PATCH] feat: ignore `node_modules` folder in `projects` option glob (#105) replace `glob` with `globby`, same as `typescript-eslint` --- package.json | 2 +- src/index.ts | 19 ++++++++++++------- yarn.lock | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 382e6ce..f6b8431 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ }, "dependencies": { "debug": "^4.3.4", - "glob": "^7.2.0", + "globby": "^11.1.0", "is-glob": "^4.0.3", "resolve": "^1.22.0", "tsconfig-paths": "^4.0.0" diff --git a/src/index.ts b/src/index.ts index 55ee267..f4ed21a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import path from 'path' import debug from 'debug' -import { sync as globSync } from 'glob' +import { sync as globSync } from 'globby' import isGlob from 'is-glob' import { isCore, sync, SyncOpts } from 'resolve' import { @@ -287,12 +287,17 @@ function initMappers(options: TsResolverOptions) { ? options.project : [process.cwd()] - mappers = configPaths - // turn glob patterns into paths - .reduce( - (paths, path) => [...paths, ...(isGlob(path) ? globSync(path) : [path])], - [], - ) + const ignore = ['!**/node_modules/**'] + + // turn glob patterns into paths + const projectPaths = [ + ...new Set([ + ...configPaths.filter(path => !isGlob(path)), + ...globSync([...configPaths.filter(path => isGlob(path)), ...ignore]), + ]), + ] + + mappers = projectPaths .map(loadConfig) .filter(isConfigLoaderSuccessResult) .map(configLoaderResult => { diff --git a/yarn.lock b/yarn.lock index c915c2c..0bd492b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5317,7 +5317,7 @@ globby@10.0.1: merge2 "^1.2.3" slash "^3.0.0" -globby@^11.0.1, globby@^11.0.4: +globby@^11.0.1, globby@^11.0.4, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==