@vercel/build-utils
Advanced tools
Comparing version 5.7.5 to 5.8.2
@@ -41,2 +41,7 @@ "use strict"; | ||
const { mode } = file; | ||
if (isDirectory(mode)) { | ||
await fs_extra_1.mkdirp(fsPath); | ||
await fs_extra_1.chmod(fsPath, mode); | ||
return file_fs_ref_1.default.fromFsPath({ mode, fsPath }); | ||
} | ||
// If the source is a symlink, try to create it instead of copying the file. | ||
@@ -43,0 +48,0 @@ // Note: creating symlinks on Windows requires admin priviliges or symlinks |
@@ -15,9 +15,3 @@ "use strict"; | ||
async function glob(pattern, opts, mountpoint) { | ||
let options; | ||
if (typeof opts === 'string') { | ||
options = { cwd: opts }; | ||
} | ||
else { | ||
options = opts; | ||
} | ||
const options = typeof opts === 'string' ? { cwd: opts } : opts; | ||
if (!options.cwd) { | ||
@@ -31,7 +25,12 @@ throw new Error('Second argument (basePath) must be specified for names of resulting files'); | ||
const statCache = {}; | ||
options.symlinks = {}; | ||
options.statCache = statCache; | ||
options.stat = true; | ||
options.dot = true; | ||
const files = await vanillaGlob(pattern, options); | ||
const symlinks = {}; | ||
const files = await vanillaGlob(pattern, { | ||
...options, | ||
symlinks, | ||
statCache, | ||
stat: true, | ||
dot: true, | ||
}); | ||
const dirs = new Set(); | ||
const dirsWithEntries = new Set(); | ||
for (const relativePath of files) { | ||
@@ -41,7 +40,14 @@ const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath)); | ||
assert_1.default(stat, `statCache does not contain value for ${relativePath} (resolved to ${fsPath})`); | ||
const isSymlink = options.symlinks[fsPath]; | ||
if (isSymlink || stat.isFile()) { | ||
const isSymlink = symlinks[fsPath]; | ||
if (isSymlink || stat.isFile() || stat.isDirectory()) { | ||
if (isSymlink) { | ||
stat = await fs_extra_1.lstat(fsPath); | ||
} | ||
// Some bookkeeping to track which directories already have entries within | ||
const dirname = path_1.default.dirname(relativePath); | ||
dirsWithEntries.add(dirname); | ||
if (stat.isDirectory()) { | ||
dirs.add(relativePath); | ||
continue; | ||
} | ||
let finalPath = relativePath; | ||
@@ -54,4 +60,16 @@ if (mountpoint) { | ||
} | ||
// Add empty directory entries | ||
for (const relativePath of dirs) { | ||
if (dirsWithEntries.has(relativePath)) | ||
continue; | ||
let finalPath = relativePath; | ||
if (mountpoint) { | ||
finalPath = path_1.default.join(mountpoint, finalPath); | ||
} | ||
const fsPath = normalize_path_1.normalizePath(path_1.default.join(options.cwd, relativePath)); | ||
const stat = statCache[fsPath]; | ||
results[finalPath] = new file_fs_ref_1.default({ mode: stat.mode, fsPath }); | ||
} | ||
return results; | ||
} | ||
exports.default = glob; |
@@ -63,2 +63,5 @@ "use strict"; | ||
return resolve({ | ||
// ignoring the next line due to do some Node.js type issue when we removed hoisting of dependencies in https://github.com/vercel/vercel/pull/9198 | ||
// should eventually be fixed when this method is remove by https://github.com/vercel/vercel/pull/9200 or we update to Node 16 | ||
// @ts-ignore | ||
code, | ||
@@ -65,0 +68,0 @@ stdout: Buffer.concat(stdoutList).toString(), |
@@ -7,3 +7,3 @@ import FileBlob from './file-blob'; | ||
import { Prerender } from './prerender'; | ||
import download, { downloadFile, DownloadedFiles, isSymbolicLink } from './fs/download'; | ||
import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory } from './fs/download'; | ||
import getWriteableDirectory from './fs/get-writable-directory'; | ||
@@ -20,3 +20,3 @@ import glob, { GlobOptions } from './fs/glob'; | ||
import { cloneEnv } from './clone-env'; | ||
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, }; | ||
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, }; | ||
export { EdgeFunction } from './edge-function'; | ||
@@ -23,0 +23,0 @@ export { readConfigFile } from './fs/read-config-file'; |
{ | ||
"name": "@vercel/build-utils", | ||
"version": "5.7.5", | ||
"version": "5.8.2", | ||
"license": "MIT", | ||
@@ -16,4 +16,4 @@ "main": "./dist/index.js", | ||
"test": "jest --env node --verbose --runInBand --bail", | ||
"test-unit": "yarn test test/unit.*test.*", | ||
"test-integration-once": "yarn test test/integration.test.ts" | ||
"test-unit": "pnpm test test/unit.*test.*", | ||
"test-integration-once": "pnpm test test/integration.test.ts" | ||
}, | ||
@@ -29,4 +29,6 @@ "devDependencies": { | ||
"@types/js-yaml": "3.12.1", | ||
"@types/minimatch": "^5.1.2", | ||
"@types/ms": "0.7.31", | ||
"@types/multistream": "2.1.1", | ||
"@types/node": "14.18.33", | ||
"@types/node-fetch": "^2.1.6", | ||
@@ -41,4 +43,6 @@ "@types/semver": "6.0.0", | ||
"end-of-stream": "1.4.1", | ||
"execa": "3.2.0", | ||
"fs-extra": "10.0.0", | ||
"glob": "8.0.3", | ||
"ignore": "4.0.6", | ||
"into-stream": "5.0.0", | ||
@@ -53,3 +57,3 @@ "js-yaml": "3.13.1", | ||
}, | ||
"gitHead": "4c3bc0532216f21f354623ada76b2315ef8ba519" | ||
"gitHead": "e54da8a2e5504987a956e2baaad6d817028b597f" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1537172
31544
33