Skip to content

Commit 1e1b5a6

Browse files
authoredJun 25, 2022
feat: ignore node_modules folder in projects option glob (import-js#105)
replace `glob` with `globby`, same as `typescript-eslint`
1 parent b2edbc8 commit 1e1b5a6

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
},
6161
"dependencies": {
6262
"debug": "^4.3.4",
63-
"glob": "^7.2.0",
63+
"globby": "^11.1.0",
6464
"is-glob": "^4.0.3",
6565
"resolve": "^1.22.0",
6666
"tsconfig-paths": "^4.0.0"

‎src/index.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path'
22

33
import debug from 'debug'
4-
import { sync as globSync } from 'glob'
4+
import { sync as globSync } from 'globby'
55
import isGlob from 'is-glob'
66
import { isCore, sync, SyncOpts } from 'resolve'
77
import {
@@ -287,12 +287,17 @@ function initMappers(options: TsResolverOptions) {
287287
? options.project
288288
: [process.cwd()]
289289

290-
mappers = configPaths
291-
// turn glob patterns into paths
292-
.reduce<string[]>(
293-
(paths, path) => [...paths, ...(isGlob(path) ? globSync(path) : [path])],
294-
[],
295-
)
290+
const ignore = ['!**/node_modules/**']
291+
292+
// turn glob patterns into paths
293+
const projectPaths = [
294+
...new Set([
295+
...configPaths.filter(path => !isGlob(path)),
296+
...globSync([...configPaths.filter(path => isGlob(path)), ...ignore]),
297+
]),
298+
]
299+
300+
mappers = projectPaths
296301
.map(loadConfig)
297302
.filter(isConfigLoaderSuccessResult)
298303
.map(configLoaderResult => {

‎yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -5317,7 +5317,7 @@ globby@10.0.1:
53175317
merge2 "^1.2.3"
53185318
slash "^3.0.0"
53195319

5320-
globby@^11.0.1, globby@^11.0.4:
5320+
globby@^11.0.1, globby@^11.0.4, globby@^11.1.0:
53215321
version "11.1.0"
53225322
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
53235323
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==

0 commit comments

Comments
 (0)