Skip to content

Commit d5e6f2a

Browse files
committed
fix(deps): replace glob with fast-glob
1 parent 5289c05 commit d5e6f2a

File tree

9 files changed

+22
-92
lines changed

9 files changed

+22
-92
lines changed

package-lock.json

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

packages/zip-it-and-ship-it/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
"es-module-lexer": "^1.0.0",
5353
"esbuild": "0.25.4",
5454
"execa": "^8.0.0",
55-
"fast-glob": "^3.3.2",
55+
"fast-glob": "^3.3.3",
5656
"filter-obj": "^6.0.0",
5757
"find-up": "^7.0.0",
58-
"glob": "^8.0.3",
5958
"is-builtin-module": "^3.1.0",
6059
"is-path-inside": "^4.0.0",
6160
"junk": "^4.0.0",
@@ -78,7 +77,6 @@
7877
},
7978
"devDependencies": {
8079
"@types/archiver": "6.0.3",
81-
"@types/glob": "8.1.0",
8280
"@types/is-ci": "3.0.4",
8381
"@types/node": "20.12.11",
8482
"@types/normalize-path": "3.0.2",

packages/zip-it-and-ship-it/src/runtimes/node/bundlers/esbuild/bundler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ const includedFilesToEsbuildExternals = async (includedFiles: string[], baseDir:
6060

6161
if (hasMultipleGlobs) {
6262
const resolved = await glob(pattern, {
63-
noglobstar: true,
63+
globstar: false,
6464
cwd: baseDir,
6565
})
6666

67-
result.push(...resolved)
67+
// esbuild expects relative paths, but tinyglobby uses `posix.normalize()` which strips leading `./`
68+
const esbuildPatterns = resolved.map((pattern) => `./${pattern}`)
69+
result.push(...esbuildPatterns)
6870
} else {
6971
result.push(pattern)
7072
}

packages/zip-it-and-ship-it/src/runtimes/node/bundlers/nft/side_files.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export const getSideFiles = async function (functionPath: string, stat: Stats):
1717
const paths = await glob(`${functionPath}/**`, {
1818
absolute: true,
1919
cwd: functionPath,
20-
ignore: `**/node_modules/**`,
21-
nodir: true,
20+
ignore: [`**/node_modules/**`],
2221
})
2322

2423
return paths.filter((path) => !isJunk(basename(path)))

packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/published.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const getPublishedFiles = async function (modulePath: string): Promise<st
55
const ignore = getIgnoredFiles(modulePath)
66
const publishedFiles = await glob(`${modulePath}/**`, {
77
ignore,
8-
nodir: true,
98
absolute: true,
109
dot: true,
1110
})

packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/tree_files.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export const getTreeFiles = async function (srcPath: string, stat: Stats): Promi
99
}
1010

1111
return await glob(`${srcPath}/**`, {
12-
ignore: `${srcPath}/**/node_modules/**`,
13-
nodir: true,
12+
ignore: [`${srcPath}/**/node_modules/**`],
1413
absolute: true,
1514
})
1615
}

packages/zip-it-and-ship-it/src/runtimes/node/utils/included_files.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { normalize, resolve } from 'path'
22

3-
import fastGlob from 'fast-glob'
3+
import glob from 'fast-glob'
44

55
import { minimatch } from '../../../utils/matching.js'
66

@@ -48,7 +48,7 @@ export const getPathsOfIncludedFiles = async (
4848
{ include: [], excludePatterns: [] },
4949
)
5050

51-
const pathGroups = await fastGlob(include, {
51+
const pathGroups = await glob(include, {
5252
absolute: true,
5353
cwd: basePath,
5454
dot: true,

packages/zip-it-and-ship-it/src/utils/matching.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import { promisify } from 'util'
2-
3-
import globFunction from 'glob'
4-
import { minimatch as minimatchFunction, MinimatchOptions } from 'minimatch'
1+
import originalGlob from 'fast-glob'
2+
import { minimatch as minimatchFunction, type MinimatchOptions } from 'minimatch'
53
import normalizePath from 'normalize-path'
64

7-
const pGlob = promisify(globFunction)
8-
95
/**
106
* Both glob and minimatch only support unix style slashes in patterns
11-
* For this reason we wrap them and ensure all patters are always unixified
7+
* For this reason we wrap them and ensure all patterns are always unixified
128
* We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters
139
*/
14-
15-
export const glob = function (pattern: string, options: globFunction.IOptions): Promise<string[]> {
16-
let normalizedIgnore
17-
18-
if (options.ignore) {
19-
normalizedIgnore =
20-
typeof options.ignore === 'string'
21-
? normalizePath(options.ignore)
22-
: options.ignore.map((expression) => normalizePath(expression))
23-
}
24-
25-
return pGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore })
10+
export const glob = function (pattern: string, options: originalGlob.Options): Promise<string[]> {
11+
const normalizedIgnore = options.ignore?.map((expression) => normalizePath(expression))
12+
return originalGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore })
2613
}
2714

2815
export const minimatch = function (target: string, pattern: string, options?: MinimatchOptions): boolean {

packages/zip-it-and-ship-it/tests/v2api.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { readFile } from 'fs/promises'
22
import { join, resolve } from 'path'
3-
import { platform, version as nodeVersion } from 'process'
4-
import { promisify } from 'util'
3+
import { platform } from 'process'
54

65
import { getPath as getBootstrapPath } from '@netlify/serverless-functions-api'
76
import merge from 'deepmerge'
8-
import glob from 'glob'
7+
import glob from 'fast-glob'
98
import { pathExists } from 'path-exists'
10-
import semver from 'semver'
119
import { dir as getTmpDir } from 'tmp-promise'
1210
import { afterEach, describe, expect, test, vi } from 'vitest'
1311

@@ -18,11 +16,9 @@ import { invokeLambda, readAsBuffer } from './helpers/lambda.js'
1816
import { zipFixture, unzipFiles, importFunctionFile, FIXTURES_ESM_DIR, FIXTURES_DIR } from './helpers/main.js'
1917
import { testMany } from './helpers/test_many.js'
2018

21-
const pGlob = promisify(glob)
22-
2319
vi.mock('../src/utils/shell.js', () => ({ shellUtils: { runCommand: vi.fn() } }))
2420

25-
describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {
21+
describe('V2 functions API', () => {
2622
afterEach(() => {
2723
vi.resetAllMocks()
2824
})
@@ -132,7 +128,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {
132128

133129
const [{ name: archive, entryFilename, path }] = files
134130

135-
const untranspiledFiles = await pGlob(`${path}/**/*.ts`)
131+
const untranspiledFiles = await glob(`${path}/**/*.ts`)
136132
expect(untranspiledFiles).toEqual([])
137133

138134
const func = await importFunctionFile(`${tmpDir}/${archive}/${entryFilename}`)

0 commit comments

Comments
 (0)