Replace the glob package with node:fs glob (#63231) · github/docs@b729e5e · GitHub
Skip to content

Commit b729e5e

Browse files
heiskrCopilot
andauthored
Replace the glob package with node:fs glob (#63231)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35abb1df-6285-443c-892a-30c594d2d64c
1 parent abc734b commit b729e5e

7 files changed

Lines changed: 34 additions & 35 deletions

File tree

‎package-lock.json‎

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

‎package.json‎

Lines changed: 0 additions & 1 deletion

‎src/frame/tests/secure-files.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import fs from 'fs/promises'
22

33
import { describe, expect, test } from 'vitest'
4-
import { glob } from 'glob'
54

65
/*
76
* Verify that a list of file paths are present and optionally have a CODEOWNERS entry
@@ -29,7 +28,7 @@ const codeOwners = codeOwnersFile.split(/\r?\n/)
2928
describe('Secure file paths are present and have code owners if required', () => {
3029
for (const file of secureFiles) {
3130
test(`secure file(s) check for: ${file.name}`, async () => {
32-
const matchingFiles = await glob(file.path)
31+
const matchingFiles = await Array.fromAsync(fs.glob(file.path))
3332
expect(matchingFiles.length, `Expected to find content in "${file.path}"`).toBeGreaterThan(0)
3433

3534
if (file.requiredCodeOwner) {

‎src/links/scripts/check-links-external.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import { program } from 'commander'
2121
import chalk from 'chalk'
2222
import fs from 'fs'
23-
import { glob } from 'glob'
2423
import { JSONFilePreset } from 'lowdb/node'
2524

2625
import { extractLinksFromMarkdown } from '@/links/lib/extract-links'
@@ -297,7 +296,9 @@ async function checkGithubRepoUrl(
297296
async function extractAllExternalLinks(): Promise<Map<string, LinkOccurrence[]>> {
298297
const links = new Map<string, LinkOccurrence[]>()
299298

300-
const files = await glob('content/**/*.md', { ignore: '**/README.md' })
299+
const files = await Array.fromAsync(
300+
fs.promises.glob('content/**/*.md', { exclude: ['**/README.md'] }),
301+
)
301302
console.log(`Found ${files.length} Markdown files to scan`)
302303

303304
const extractStart = Date.now()

‎src/links/scripts/check-links-pr.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ async function main() {
350350

351351
if (options.all) {
352352
// For testing: check all content files (limited)
353-
const glob = await import('glob')
354-
files = glob.sync('content/**/*.md').slice(0, 50)
353+
const { globSync } = await import('node:fs')
354+
files = globSync('content/**/*.md').sort().slice(0, 50)
355355
console.log(`Checking ${files.length} files (--all mode, limited to 50)`)
356356
} else if (files.length === 0) {
357357
console.log('No files to check. Exiting.')

‎src/rest/scripts/openapi-check.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import fs from 'fs'
88
import path from 'path'
9-
import { globSync } from 'glob'
109
import { program } from 'commander'
1110
import { createOperations, processOperations, type SchemaInput } from './utils/get-operations'
1211

@@ -24,7 +23,7 @@ program
2423

2524
const filenames: string[] = (program.opts() as ProgramOptions).files
2625

27-
const filesToCheck: string[] = filenames.flatMap((filename: string) => globSync(filename))
26+
const filesToCheck: string[] = filenames.flatMap((filename: string) => fs.globSync(filename))
2827

2928
if (filesToCheck.length) {
3029
check(filesToCheck)

‎src/workflows/writers-help-metadata.ts‎

Lines changed: 24 additions & 8 deletions

0 commit comments

Comments
 (0)