@vercel/build-utils 6.3.4 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hard-link-dir.d.ts +1 -0
- package/dist/hard-link-dir.js +84 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +95 -1
- package/package.json +2 -2
@@ -0,0 +1 @@
|
|
1
|
+
export declare function hardLinkDir(src: string, destDirs: string[]): Promise<void>;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
"use strict";
|
2
|
+
// Source: https://github.com/pnpm/pnpm/blob/b38d711f3892a473e20e69dd32ca7e1b439efaec/fs/hard-link-dir/src/index.ts#L4
|
3
|
+
// LICENSE (MIT): https://github.com/pnpm/pnpm/blob/b38d711f3892a473e20e69dd32ca7e1b439efaec/LICENSE
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
6
|
+
};
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
8
|
+
exports.hardLinkDir = void 0;
|
9
|
+
const path_1 = __importDefault(require("path"));
|
10
|
+
const fs_1 = require("fs");
|
11
|
+
async function hardLinkDir(src, destDirs) {
|
12
|
+
if (destDirs.length === 0)
|
13
|
+
return;
|
14
|
+
// Don't try to hard link the source directory to itself
|
15
|
+
destDirs = destDirs.filter(destDir => path_1.default.relative(destDir, src) !== '');
|
16
|
+
const files = await fs_1.promises.readdir(src);
|
17
|
+
await Promise.all(files.map(async (file) => {
|
18
|
+
if (file === 'node_modules')
|
19
|
+
return;
|
20
|
+
const srcFile = path_1.default.join(src, file);
|
21
|
+
if ((await fs_1.promises.lstat(srcFile)).isDirectory()) {
|
22
|
+
const destSubdirs = await Promise.all(destDirs.map(async (destDir) => {
|
23
|
+
const destSubdir = path_1.default.join(destDir, file);
|
24
|
+
try {
|
25
|
+
await fs_1.promises.mkdir(destSubdir, { recursive: true });
|
26
|
+
}
|
27
|
+
catch (err) {
|
28
|
+
// eslint-disable-line
|
29
|
+
if (err.code !== 'EEXIST')
|
30
|
+
throw err;
|
31
|
+
}
|
32
|
+
return destSubdir;
|
33
|
+
}));
|
34
|
+
await hardLinkDir(srcFile, destSubdirs);
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
await Promise.all(destDirs.map(async (destDir) => {
|
38
|
+
const destFile = path_1.default.join(destDir, file);
|
39
|
+
try {
|
40
|
+
await linkOrCopyFile(srcFile, destFile);
|
41
|
+
}
|
42
|
+
catch (err) {
|
43
|
+
// eslint-disable-line
|
44
|
+
if (err.code === 'ENOENT') {
|
45
|
+
// Ignore broken symlinks
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
throw err;
|
49
|
+
}
|
50
|
+
}));
|
51
|
+
}));
|
52
|
+
}
|
53
|
+
exports.hardLinkDir = hardLinkDir;
|
54
|
+
async function linkOrCopyFile(srcFile, destFile) {
|
55
|
+
try {
|
56
|
+
await linkOrCopy(srcFile, destFile);
|
57
|
+
}
|
58
|
+
catch (err) {
|
59
|
+
// eslint-disable-line
|
60
|
+
if (err.code === 'ENOENT') {
|
61
|
+
await fs_1.promises.mkdir(path_1.default.dirname(destFile), { recursive: true });
|
62
|
+
await linkOrCopy(srcFile, destFile);
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
if (err.code !== 'EEXIST') {
|
66
|
+
throw err;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
/*
|
71
|
+
* This function could be optimized because we don't really need to try linking again
|
72
|
+
* if linking failed once.
|
73
|
+
*/
|
74
|
+
async function linkOrCopy(srcFile, destFile) {
|
75
|
+
try {
|
76
|
+
await fs_1.promises.link(srcFile, destFile);
|
77
|
+
}
|
78
|
+
catch (err) {
|
79
|
+
// eslint-disable-line
|
80
|
+
if (err.code !== 'EXDEV')
|
81
|
+
throw err;
|
82
|
+
await fs_1.promises.copyFile(srcFile, destFile);
|
83
|
+
}
|
84
|
+
}
|
package/dist/index.d.ts
CHANGED
@@ -16,7 +16,8 @@ import getIgnoreFilter from './get-ignore-filter';
|
|
16
16
|
import { getPlatformEnv } from './get-platform-env';
|
17
17
|
import { getPrefixedEnvVars } from './get-prefixed-env-vars';
|
18
18
|
import { cloneEnv } from './clone-env';
|
19
|
-
|
19
|
+
import { hardLinkDir } from './hard-link-dir';
|
20
|
+
export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, 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, hardLinkDir, };
|
20
21
|
export { EdgeFunction } from './edge-function';
|
21
22
|
export { readConfigFile } from './fs/read-config-file';
|
22
23
|
export { normalizePath } from './fs/normalize-path';
|
package/dist/index.js
CHANGED
@@ -31622,6 +31622,98 @@ function getPrefixedEnvVars({ envPrefix, envs, }) {
|
|
31622
31622
|
exports.getPrefixedEnvVars = getPrefixedEnvVars;
|
31623
31623
|
|
31624
31624
|
|
31625
|
+
/***/ }),
|
31626
|
+
|
31627
|
+
/***/ 7264:
|
31628
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
31629
|
+
|
31630
|
+
"use strict";
|
31631
|
+
|
31632
|
+
// Source: https://github.com/pnpm/pnpm/blob/b38d711f3892a473e20e69dd32ca7e1b439efaec/fs/hard-link-dir/src/index.ts#L4
|
31633
|
+
// LICENSE (MIT): https://github.com/pnpm/pnpm/blob/b38d711f3892a473e20e69dd32ca7e1b439efaec/LICENSE
|
31634
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
31635
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
31636
|
+
};
|
31637
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
31638
|
+
exports.hardLinkDir = void 0;
|
31639
|
+
const path_1 = __importDefault(__webpack_require__(5622));
|
31640
|
+
const fs_1 = __webpack_require__(5747);
|
31641
|
+
async function hardLinkDir(src, destDirs) {
|
31642
|
+
if (destDirs.length === 0)
|
31643
|
+
return;
|
31644
|
+
// Don't try to hard link the source directory to itself
|
31645
|
+
destDirs = destDirs.filter(destDir => path_1.default.relative(destDir, src) !== '');
|
31646
|
+
const files = await fs_1.promises.readdir(src);
|
31647
|
+
await Promise.all(files.map(async (file) => {
|
31648
|
+
if (file === 'node_modules')
|
31649
|
+
return;
|
31650
|
+
const srcFile = path_1.default.join(src, file);
|
31651
|
+
if ((await fs_1.promises.lstat(srcFile)).isDirectory()) {
|
31652
|
+
const destSubdirs = await Promise.all(destDirs.map(async (destDir) => {
|
31653
|
+
const destSubdir = path_1.default.join(destDir, file);
|
31654
|
+
try {
|
31655
|
+
await fs_1.promises.mkdir(destSubdir, { recursive: true });
|
31656
|
+
}
|
31657
|
+
catch (err) {
|
31658
|
+
// eslint-disable-line
|
31659
|
+
if (err.code !== 'EEXIST')
|
31660
|
+
throw err;
|
31661
|
+
}
|
31662
|
+
return destSubdir;
|
31663
|
+
}));
|
31664
|
+
await hardLinkDir(srcFile, destSubdirs);
|
31665
|
+
return;
|
31666
|
+
}
|
31667
|
+
await Promise.all(destDirs.map(async (destDir) => {
|
31668
|
+
const destFile = path_1.default.join(destDir, file);
|
31669
|
+
try {
|
31670
|
+
await linkOrCopyFile(srcFile, destFile);
|
31671
|
+
}
|
31672
|
+
catch (err) {
|
31673
|
+
// eslint-disable-line
|
31674
|
+
if (err.code === 'ENOENT') {
|
31675
|
+
// Ignore broken symlinks
|
31676
|
+
return;
|
31677
|
+
}
|
31678
|
+
throw err;
|
31679
|
+
}
|
31680
|
+
}));
|
31681
|
+
}));
|
31682
|
+
}
|
31683
|
+
exports.hardLinkDir = hardLinkDir;
|
31684
|
+
async function linkOrCopyFile(srcFile, destFile) {
|
31685
|
+
try {
|
31686
|
+
await linkOrCopy(srcFile, destFile);
|
31687
|
+
}
|
31688
|
+
catch (err) {
|
31689
|
+
// eslint-disable-line
|
31690
|
+
if (err.code === 'ENOENT') {
|
31691
|
+
await fs_1.promises.mkdir(path_1.default.dirname(destFile), { recursive: true });
|
31692
|
+
await linkOrCopy(srcFile, destFile);
|
31693
|
+
return;
|
31694
|
+
}
|
31695
|
+
if (err.code !== 'EEXIST') {
|
31696
|
+
throw err;
|
31697
|
+
}
|
31698
|
+
}
|
31699
|
+
}
|
31700
|
+
/*
|
31701
|
+
* This function could be optimized because we don't really need to try linking again
|
31702
|
+
* if linking failed once.
|
31703
|
+
*/
|
31704
|
+
async function linkOrCopy(srcFile, destFile) {
|
31705
|
+
try {
|
31706
|
+
await fs_1.promises.link(srcFile, destFile);
|
31707
|
+
}
|
31708
|
+
catch (err) {
|
31709
|
+
// eslint-disable-line
|
31710
|
+
if (err.code !== 'EXDEV')
|
31711
|
+
throw err;
|
31712
|
+
await fs_1.promises.copyFile(srcFile, destFile);
|
31713
|
+
}
|
31714
|
+
}
|
31715
|
+
|
31716
|
+
|
31625
31717
|
/***/ }),
|
31626
31718
|
|
31627
31719
|
/***/ 9037:
|
@@ -31655,7 +31747,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31655
31747
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
31656
31748
|
};
|
31657
31749
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
31658
|
-
exports.normalizePath = exports.readConfigFile = exports.EdgeFunction = exports.cloneEnv = exports.getIgnoreFilter = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isDirectory = exports.isSymbolicLink = exports.debug = exports.streamToBuffer = exports.getPrefixedEnvVars = exports.getPlatformEnv = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.getEnvForPackageManager = exports.runCustomInstallCommand = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.downloadFile = exports.download = exports.Prerender = exports.createLambda = exports.NodejsLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
|
31750
|
+
exports.normalizePath = exports.readConfigFile = exports.EdgeFunction = exports.hardLinkDir = exports.cloneEnv = exports.getIgnoreFilter = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isDirectory = exports.isSymbolicLink = exports.debug = exports.streamToBuffer = exports.getPrefixedEnvVars = exports.getPlatformEnv = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.getEnvForPackageManager = exports.runCustomInstallCommand = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.downloadFile = exports.download = exports.Prerender = exports.createLambda = exports.NodejsLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
|
31659
31751
|
const file_blob_1 = __importDefault(__webpack_require__(8361));
|
31660
31752
|
exports.FileBlob = file_blob_1.default;
|
31661
31753
|
const file_fs_ref_1 = __importDefault(__webpack_require__(6274));
|
@@ -31714,6 +31806,8 @@ const get_prefixed_env_vars_1 = __webpack_require__(2229);
|
|
31714
31806
|
Object.defineProperty(exports, "getPrefixedEnvVars", ({ enumerable: true, get: function () { return get_prefixed_env_vars_1.getPrefixedEnvVars; } }));
|
31715
31807
|
const clone_env_1 = __webpack_require__(651);
|
31716
31808
|
Object.defineProperty(exports, "cloneEnv", ({ enumerable: true, get: function () { return clone_env_1.cloneEnv; } }));
|
31809
|
+
const hard_link_dir_1 = __webpack_require__(7264);
|
31810
|
+
Object.defineProperty(exports, "hardLinkDir", ({ enumerable: true, get: function () { return hard_link_dir_1.hardLinkDir; } }));
|
31717
31811
|
var edge_function_1 = __webpack_require__(323);
|
31718
31812
|
Object.defineProperty(exports, "EdgeFunction", ({ enumerable: true, get: function () { return edge_function_1.EdgeFunction; } }));
|
31719
31813
|
var read_config_file_1 = __webpack_require__(2212);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.4.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.js",
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"typescript": "4.3.4",
|
52
52
|
"yazl": "2.5.1"
|
53
53
|
},
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "b2c68f1301b6a5eb41b6261b7faac6a8fa4c53eb"
|
55
55
|
}
|