@vercel/go 3.4.5 → 3.4.6

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 +42 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -14171,6 +14171,32 @@ var goGlobalCachePath = (0, import_path4.join)(
14171
14171
  "golang"
14172
14172
  );
14173
14173
  var OUT_EXTENSION = process.platform === "win32" ? ".exe" : "";
14174
+ function getGoCommandOutput(error) {
14175
+ const stderr = error.stderr?.trim();
14176
+ const stdout = error.stdout?.trim();
14177
+ const all = error.all?.trim();
14178
+ if (stderr && stdout && stdout !== stderr) {
14179
+ return `stderr:
14180
+ ${stderr}
14181
+
14182
+ stdout:
14183
+ ${stdout}`;
14184
+ }
14185
+ return stderr || stdout || all;
14186
+ }
14187
+ function enrichGoCommandError(error) {
14188
+ if (!(error instanceof Error)) {
14189
+ return error;
14190
+ }
14191
+ const output = getGoCommandOutput(error);
14192
+ if (!output || error.message.includes(output)) {
14193
+ return error;
14194
+ }
14195
+ error.message = `${error.message}
14196
+
14197
+ ${output}`;
14198
+ return error;
14199
+ }
14174
14200
  async function getAnalyzedEntrypoint({
14175
14201
  entrypoint,
14176
14202
  modulePath,
@@ -14233,7 +14259,7 @@ var GoWrapper = class {
14233
14259
  this.env = env;
14234
14260
  this.opts = opts;
14235
14261
  }
14236
- execute(...args) {
14262
+ async execute(...args) {
14237
14263
  const { opts, env } = this;
14238
14264
  (0, import_build_utils.debug)(
14239
14265
  `Exec: go ${args.map((a) => a.includes(" ") ? `"${a}"` : a).join(" ")}`
@@ -14241,7 +14267,21 @@ var GoWrapper = class {
14241
14267
  (0, import_build_utils.debug)(` CWD=${opts.cwd}`);
14242
14268
  (0, import_build_utils.debug)(` GOROOT=${(env || opts.env).GOROOT}`);
14243
14269
  (0, import_build_utils.debug)(` GO_BUILD_FLAGS=${(env || opts.env).GO_BUILD_FLAGS}`);
14244
- return (0, import_execa.default)("go", args, { stdio: "inherit", ...opts, env });
14270
+ const captureAndForwardOutput = opts.stdio === void 0 || opts.stdio === "inherit";
14271
+ const subprocess = (0, import_execa.default)("go", args, {
14272
+ ...opts,
14273
+ env,
14274
+ stdio: captureAndForwardOutput ? "pipe" : opts.stdio
14275
+ });
14276
+ if (captureAndForwardOutput) {
14277
+ subprocess.stdout?.pipe(process.stdout);
14278
+ subprocess.stderr?.pipe(process.stderr);
14279
+ }
14280
+ try {
14281
+ return await subprocess;
14282
+ } catch (error) {
14283
+ throw enrichGoCommandError(error);
14284
+ }
14245
14285
  }
14246
14286
  mod() {
14247
14287
  return this.execute("mod", "tidy");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/go",
3
- "version": "3.4.5",
3
+ "version": "3.4.6",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
@@ -32,7 +32,7 @@
32
32
  "typescript": "4.9.5",
33
33
  "xdg-app-paths": "5.1.0",
34
34
  "yauzl-promise": "2.1.3",
35
- "@vercel/build-utils": "13.8.0"
35
+ "@vercel/build-utils": "13.8.2"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "node ../../utils/build-builder.mjs",