Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore node_modules folder in projects option glob #105

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = [
JounQin marked this conversation as resolved.
Show resolved Hide resolved
...new Set([
...configPaths.filter(path => !isGlob(path)),
...globSync([...configPaths.filter(path => isGlob(path)), ...ignore]),
]),
]

mappers = projectPaths
.map(loadConfig)
.filter(isConfigLoaderSuccessResult)
.map(configLoaderResult => {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5317,9 +5317,9 @@ 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"
resolved "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
stefanprobst marked this conversation as resolved.
Show resolved Hide resolved
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
dependencies:
array-union "^2.1.0"
Expand Down