Skip to content

Commit a10e280

Browse files
committed
chore(deps): switch from fast-glob to tinyglobby
1 parent 78b7da5 commit a10e280

File tree

7 files changed

+31
-23
lines changed

7 files changed

+31
-23
lines changed

package-lock.json

Lines changed: 6 additions & 7 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"es-module-lexer": "^1.0.0",
5353
"esbuild": "0.25.5",
5454
"execa": "^8.0.0",
55-
"fast-glob": "^3.3.3",
5655
"filter-obj": "^6.0.0",
5756
"find-up": "^7.0.0",
5857
"is-builtin-module": "^3.1.0",
@@ -68,6 +67,7 @@
6867
"require-package-name": "^2.0.1",
6968
"resolve": "^2.0.0-next.1",
7069
"semver": "^7.3.8",
70+
"tinyglobby": "https://pkg.pr.new/tinyglobby@131",
7171
"tmp-promise": "^3.0.2",
7272
"toml": "^3.0.0",
7373
"unixify": "^1.0.0",

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { normalize, resolve } from 'path'
2+
import { lstatSync } from 'fs'
23

3-
import glob from 'fast-glob'
4+
import { glob } from 'tinyglobby'
45

56
import { minimatch } from '../../../utils/matching.js'
67

@@ -54,14 +55,21 @@ export const getPathsOfIncludedFiles = async (
5455
dot: true,
5556
ignore: excludePatterns,
5657
onlyFiles: false,
57-
// get directories as well to get symlinked directories,
58-
// to filter the regular non symlinked directories out mark them with a slash at the end to filter them out.
59-
markDirectories: true,
6058
followSymbolicLinks: false,
59+
expandDirectories: false,
6160
})
6261

63-
const paths = pathGroups.filter((path) => !path.endsWith('/')).map(normalize)
62+
const paths = pathGroups.filter(pathFilter).map(normalize)
6463

6564
// now filter the non symlinked directories out that got marked with a trailing slash
6665
return { excludePatterns, paths }
6766
}
67+
68+
function pathFilter(path: string) {
69+
try {
70+
const stats = lstatSync(path)
71+
return !stats.isDirectory() || stats.isSymbolicLink()
72+
} catch (err) {
73+
return false
74+
}
75+
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import originalGlob from 'fast-glob'
21
import { minimatch as minimatchFunction, type MinimatchOptions } from 'minimatch'
32
import normalizePath from 'normalize-path'
3+
import { glob as originalGlob, type GlobOptions } from 'tinyglobby'
44

55
/**
66
* Both glob and minimatch only support unix style slashes in patterns
77
* For this reason we wrap them and ensure all patterns are always unixified
88
* We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters
99
*/
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 })
10+
export const glob = function (pattern: string, options: GlobOptions): Promise<string[]> {
11+
const ignore = Array.isArray(options.ignore) ? options.ignore : options.ignore ? [options.ignore] : []
12+
const normalizedIgnore = ignore.map((expression) => normalizePath(expression))
13+
return originalGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore, expandDirectories: false })
1314
}
1415

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import cpy from 'cpy'
66
import decompress from 'decompress'
77
import merge from 'deepmerge'
88
import { execa, execaNode } from 'execa'
9-
import glob from 'fast-glob'
109
import isCI from 'is-ci'
1110
import { pathExists } from 'path-exists'
1211
import semver from 'semver'
12+
import { glob } from 'tinyglobby'
1313
import { dir as getTmpDir, tmpName } from 'tmp-promise'
1414
import unixify from 'unixify'
1515
import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vitest'
@@ -2840,7 +2840,7 @@ describe('zip-it-and-ship-it', () => {
28402840

28412841
await decompress(files[0].path, unzipPath)
28422842

2843-
const fileNames: string[] = await glob('**', { dot: true, cwd: unzipPath })
2843+
const fileNames: string[] = await glob('**', { dot: true, cwd: unzipPath, expandDirectories: false })
28442844
const duplicates = fileNames.filter((item, index) => fileNames.indexOf(item) !== index)
28452845
expect(duplicates).toHaveLength(0)
28462846
})

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

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

33
import decompress from 'decompress'
4-
import glob from 'fast-glob'
4+
import { glob } from 'tinyglobby'
55
import { dir as getTmpDir } from 'tmp-promise'
66
import { expect, test } from 'vitest'
77

@@ -32,7 +32,7 @@ test('The telemetry file should be added by default to the function bundle', asy
3232

3333
await decompress(result!.path, unzippedPath)
3434

35-
const files = await glob('**/*', { cwd: unzippedPath })
35+
const files = await glob('**/*', { cwd: unzippedPath, expandDirectories: false })
3636
expect(files.sort()).toEqual([
3737
'___netlify-bootstrap.mjs',
3838
'___netlify-entry-point.mjs',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { platform } from 'process'
44

55
import { getPath as getBootstrapPath } from '@netlify/serverless-functions-api'
66
import merge from 'deepmerge'
7-
import glob from 'fast-glob'
87
import { pathExists } from 'path-exists'
8+
import { glob } from 'tinyglobby'
99
import { dir as getTmpDir } from 'tmp-promise'
1010
import { afterEach, describe, expect, test, vi } from 'vitest'
1111

@@ -128,7 +128,7 @@ describe('V2 functions API', () => {
128128

129129
const [{ name: archive, entryFilename, path }] = files
130130

131-
const untranspiledFiles = await glob(`${path}/**/*.ts`)
131+
const untranspiledFiles = await glob(`${path}/**/*.ts`, { expandDirectories: false })
132132
expect(untranspiledFiles).toEqual([])
133133

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

0 commit comments

Comments
 (0)