Skip to content

Commit

Permalink
feat: ignore node_modules folder in projects option glob (#105)
Browse files Browse the repository at this point in the history
replace `glob` with `globby`, same as `typescript-eslint`
  • Loading branch information
stefanprobst authored Jun 25, 2022
1 parent b2edbc8 commit 1e1b5a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 12 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -287,12 +287,17 @@ function initMappers(options: TsResolverOptions) {
? options.project
: [process.cwd()]

mappers = configPaths
// turn glob patterns into paths
.reduce<string[]>(
(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 => {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 1e1b5a6

Please sign in to comment.