Skip to content

Commit cdcff23

Browse files
fix: replace glob dependency with tinyglobby
1 parent 77841c4 commit cdcff23

File tree

3 files changed

+70
-51
lines changed

3 files changed

+70
-51
lines changed

packages/docs-builder/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"chokidar": "^3.5.3",
3939
"find-up": "^6.3.0",
4040
"gettext-parser": "^5.0.0",
41-
"glob": "^8.0.3",
4241
"gray-matter": "^4.0.3",
4342
"lunr": "^2.3.9",
4443
"lunr-languages": "^1.9.0",
@@ -48,7 +47,8 @@
4847
"postcss-rtlcss": "^5.7.1",
4948
"puppeteer": "^18.2.1",
5049
"rev-hash": "^3.0.0",
51-
"semver-compare": "^1.0.0"
50+
"semver-compare": "^1.0.0",
51+
"tinyglobby": "^0.2.15"
5252
},
5353
"devDependencies": {
5454
"@types/lunr": "^2.3.4",

packages/docs-builder/src/build.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { dirname, join as joinPath, resolve as resolvePath } from 'node:path'
44
import { fileURLToPath } from 'node:url'
55

66
import { findUp, pathExists } from 'find-up'
7-
import glob from 'glob'
87
import postcss from 'postcss'
98
import postcssRtlCss from 'postcss-rtlcss'
109
import semverCompare from 'semver-compare'
10+
import { globSync } from 'tinyglobby'
1111

1212
import { Assets } from './assets'
1313
import type { BuildMode, LangConfig } from './config'
@@ -195,9 +195,8 @@ async function buildLang(
195195
// Copy all other assets from the "shared src" directory. Note that glob paths
196196
// have forward slashes only, so convert backslashes here.
197197
const sharedSrcPath = context.config.sourceDir.replaceAll('\\', '/')
198-
const sharedSrcFiles = glob.sync(`${sharedSrcPath}/*`, { nodir: true })
199-
for (const f of sharedSrcFiles) {
200-
const relPath = f.replace(`${sharedSrcPath}/`, '')
198+
const sharedSrcFiles = globSync(`${sharedSrcPath}/*`, { cwd: sharedSrcPath, onlyFiles: true })
199+
for (const relPath of sharedSrcFiles) {
201200
if (!relPath.endsWith('.html') && !relPath.endsWith('base.css')) {
202201
copyToBase(context.config.sourceDir, relPath)
203202
}
@@ -215,9 +214,8 @@ async function buildLang(
215214
'/'
216215
)
217216
const langPath = `${localizationDir}/${lang}`
218-
const files = glob.sync(`${langPath}/images/**/*`, { nodir: true })
219-
for (const f of files) {
220-
const relPath = f.replace(`${langPath}/`, '')
217+
const files = globSync(`${langPath}/images/**/*`, { cwd: langPath, onlyFiles: true })
218+
for (const relPath of files) {
221219
assets.copyWithHash(resolvePath(langPath), relPath, context.outDir)
222220
}
223221
}

pnpm-lock.yaml

Lines changed: 63 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)