@vercel/go 3.2.4 → 3.3.1

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -17042,6 +17042,7 @@ var import_fs_extra2 = __toESM(require_lib2());
17042
17042
  var import_build_utils2 = require("@vercel/build-utils");
17043
17043
 
17044
17044
  // src/go-helpers.ts
17045
+ var import_crypto = require("crypto");
17045
17046
  var import_tar = __toESM(require_tar());
17046
17047
  var import_execa = __toESM(require_execa());
17047
17048
  var import_node_fetch = __toESM(require_lib4());
@@ -17217,15 +17218,43 @@ async function createGo({
17217
17218
  );
17218
17219
  }
17219
17220
  const setGoEnv = async (goDir) => {
17220
- if (platform !== "win32" && goDir === goGlobalCacheDir) {
17221
+ if (!goDir) {
17222
+ env.GOROOT = void 0;
17223
+ env.PATH = PATH;
17224
+ return;
17225
+ }
17226
+ const isUnix = platform !== "win32";
17227
+ const setEnvPaths = (modCache, buildCache) => {
17228
+ env.GOMODCACHE = modCache;
17229
+ env.GOCACHE = buildCache;
17230
+ (0, import_build_utils.debug)(`Set GOMODCACHE to ${env.GOMODCACHE}`);
17231
+ (0, import_build_utils.debug)(`Set GOCACHE to ${env.GOCACHE}`);
17232
+ };
17233
+ if (isUnix && goDir === goGlobalCacheDir) {
17221
17234
  (0, import_build_utils.debug)(`Symlinking ${goDir} -> ${goCacheDir}`);
17222
17235
  await (0, import_fs_extra.remove)(goCacheDir);
17223
17236
  await (0, import_fs_extra.mkdirp)((0, import_path.dirname)(goCacheDir));
17224
17237
  await (0, import_fs_extra.symlink)(goDir, goCacheDir);
17238
+ const modCache = (0, import_path.join)(goDir, "pkg", "mod");
17239
+ const buildCache = (0, import_path.join)(goDir, "go-build");
17240
+ setEnvPaths(modCache, buildCache);
17225
17241
  goDir = goCacheDir;
17226
- }
17227
- env.GOROOT = goDir || void 0;
17228
- env.PATH = goDir ? `${(0, import_path.join)(goDir, "bin")}${import_path.delimiter}${PATH}` : PATH;
17242
+ } else if (isUnix && goDir === goCacheDir) {
17243
+ const hash = (0, import_crypto.createHash)("md5").update(workPath).digest("hex").slice(0, 8);
17244
+ const tmpBase = (0, import_path.join)((0, import_os.tmpdir)(), `vercel-go-cache-${hash}`);
17245
+ const tmpModCache = (0, import_path.join)(tmpBase, "mod");
17246
+ const tmpBuildCache = (0, import_path.join)(tmpBase, "go-build");
17247
+ await (0, import_fs_extra.mkdirp)((0, import_path.join)(goDir, "pkg", "mod"));
17248
+ await (0, import_fs_extra.mkdirp)((0, import_path.join)(goDir, "go-build"));
17249
+ await (0, import_fs_extra.mkdirp)(tmpBase);
17250
+ await (0, import_fs_extra.remove)(tmpModCache);
17251
+ await (0, import_fs_extra.symlink)((0, import_path.join)(goCacheDir, "pkg", "mod"), tmpModCache);
17252
+ await (0, import_fs_extra.remove)(tmpBuildCache);
17253
+ await (0, import_fs_extra.symlink)((0, import_path.join)(goCacheDir, "go-build"), tmpBuildCache);
17254
+ setEnvPaths(tmpModCache, tmpBuildCache);
17255
+ }
17256
+ env.GOROOT = goDir;
17257
+ env.PATH = `${(0, import_path.join)(goDir, "bin")}${import_path.delimiter}${PATH}`;
17229
17258
  };
17230
17259
  const goDirs = {
17231
17260
  "local cache": goCacheDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "3.2.4",
3
+ "version": "3.3.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -33,7 +33,7 @@
33
33
  "typescript": "4.3.4",
34
34
  "xdg-app-paths": "5.1.0",
35
35
  "yauzl-promise": "2.1.3",
36
- "@vercel/build-utils": "13.2.3"
36
+ "@vercel/build-utils": "13.2.10"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "node ../../utils/build-builder.mjs",