From 81e451b5f468d41ea19ff230a55ef7fc627d089a Mon Sep 17 00:00:00 2001 From: Lukas Holzer Date: Fri, 1 Dec 2023 13:13:42 +0100 Subject: [PATCH] fix: fixes an issue where the included paths where missing symlinks and .dot directories (#1678) --- package-lock.json | 78 ++++++++++++++++------- package.json | 2 + src/runtimes/node/utils/included_files.ts | 24 +++---- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4899e57e0..86cb9de12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "es-module-lexer": "^1.0.0", "esbuild": "0.19.6", "execa": "^6.0.0", + "fast-glob": "^3.3.2", "filter-obj": "^5.0.0", "find-up": "^6.0.0", "glob": "^8.0.3", @@ -52,6 +53,7 @@ "@types/is-ci": "3.0.4", "@types/node": "14.18.63", "@types/normalize-path": "3.0.2", + "@types/picomatch": "^2.3.3", "@types/resolve": "1.20.6", "@types/semver": "7.5.6", "@types/tmp": "0.2.6", @@ -2020,6 +2022,17 @@ "node": ">= 8.0.0" } }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -2150,6 +2163,12 @@ "integrity": "sha512-DO++toKYPaFn0Z8hQ7Tx+3iT9t77IJo/nDiqTXilgEP+kPNIYdpS9kh3fXuc53ugqwp9pxC1PVjCpV1tQDyqMA==", "dev": true }, + "node_modules/@types/picomatch": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-2.3.3.tgz", + "integrity": "sha512-Yll76ZHikRFCyz/pffKGjrCwe/le2CDwOP5F210KQo27kpRE46U2rDnzikNlVn6/ezH3Mhn46bJMTfeVTtcYMg==", + "dev": true + }, "node_modules/@types/readdir-glob": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/readdir-glob/-/readdir-glob-1.1.1.tgz", @@ -5529,9 +5548,9 @@ "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" }, "node_modules/fast-glob": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz", - "integrity": "sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -7408,6 +7427,17 @@ "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -8210,17 +8240,6 @@ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/pidtree": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", @@ -12390,6 +12409,13 @@ "requires": { "estree-walker": "^2.0.1", "picomatch": "^2.2.2" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + } } }, "@sinclair/typebox": { @@ -12522,6 +12548,12 @@ "integrity": "sha512-DO++toKYPaFn0Z8hQ7Tx+3iT9t77IJo/nDiqTXilgEP+kPNIYdpS9kh3fXuc53ugqwp9pxC1PVjCpV1tQDyqMA==", "dev": true }, + "@types/picomatch": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-2.3.3.tgz", + "integrity": "sha512-Yll76ZHikRFCyz/pffKGjrCwe/le2CDwOP5F210KQo27kpRE46U2rDnzikNlVn6/ezH3Mhn46bJMTfeVTtcYMg==", + "dev": true + }, "@types/readdir-glob": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/readdir-glob/-/readdir-glob-1.1.1.tgz", @@ -14924,9 +14956,9 @@ "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==" }, "fast-glob": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz", - "integrity": "sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -16291,6 +16323,13 @@ "requires": { "braces": "^3.0.2", "picomatch": "^2.3.1" + }, + "dependencies": { + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + } } }, "mimic-fn": { @@ -16853,11 +16892,6 @@ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, "pidtree": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", diff --git a/package.json b/package.json index 1991a2b07..65f36aed4 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "es-module-lexer": "^1.0.0", "esbuild": "0.19.6", "execa": "^6.0.0", + "fast-glob": "^3.3.2", "filter-obj": "^5.0.0", "find-up": "^6.0.0", "glob": "^8.0.3", @@ -94,6 +95,7 @@ "@types/is-ci": "3.0.4", "@types/node": "14.18.63", "@types/normalize-path": "3.0.2", + "@types/picomatch": "^2.3.3", "@types/resolve": "1.20.6", "@types/semver": "7.5.6", "@types/tmp": "0.2.6", diff --git a/src/runtimes/node/utils/included_files.ts b/src/runtimes/node/utils/included_files.ts index c1857052b..6bbd2f49e 100644 --- a/src/runtimes/node/utils/included_files.ts +++ b/src/runtimes/node/utils/included_files.ts @@ -1,6 +1,8 @@ import { normalize, resolve } from 'path' -import { minimatch, glob } from '../../../utils/matching.js' +import fastGlob from 'fast-glob' + +import { minimatch } from '../../../utils/matching.js' // Returns the subset of `paths` that don't match any of the glob expressions // from `exclude`. @@ -46,16 +48,14 @@ export const getPathsOfIncludedFiles = async ( { include: [], excludePatterns: [] }, ) - const pathGroups = await Promise.all( - include.map((expression) => - glob(expression, { absolute: true, cwd: basePath, ignore: excludePatterns, nodir: true }), - ), - ) - - // `pathGroups` is an array containing the paths for each expression in the - // `include` array. We flatten it into a single dimension. - const paths = pathGroups.flat() - const normalizedPaths = paths.map(normalize) + const pathGroups = await fastGlob(include, { + absolute: true, + cwd: basePath, + dot: true, + ignore: excludePatterns, + followSymbolicLinks: true, + throwErrorOnBrokenSymbolicLink: true, + }) - return { excludePatterns, paths: [...new Set(normalizedPaths)] } + return { excludePatterns, paths: pathGroups.map(normalize) } }