Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
run go mod tidy between tool installations (#2877)
Browse files Browse the repository at this point in the history
  • Loading branch information
stamblerre authored and ramya-rao-a committed Nov 6, 2019
1 parent 21b2275 commit 077e928
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise<voi
}

return res.then(sofar => new Promise<string[]>((resolve, reject) => {
const opts = {
env: envForTools,
cwd: toolsTmpDir,
};
const callback = (err: Error, stdout: string, stderr: string) => {
// Make sure to run `go mod tidy` between tool installations.
// This avoids us having to create a fresh go.mod file for each tool.
if (!modulesOff) {
cp.execFileSync(goRuntimePath, ['mod', 'tidy'], opts);
}
if (err) {
outputChannel.appendLine('Installing ' + getImportPath(tool, goVersion) + ' FAILED');
const failureReason = tool.name + ';;' + err + stdout.toString() + stderr.toString();
Expand Down Expand Up @@ -188,10 +197,6 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise<voi
if (hasModSuffix(tool)) {
args.push('-d');
}
const opts = {
env: envForTools,
cwd: toolsTmpDir,
};
args.push(getImportPath(tool, goVersion));
cp.execFile(goRuntimePath, args, opts, (err, stdout, stderr) => {
if (stderr.indexOf('unexpected directory layout:') > -1) {
Expand Down

0 comments on commit 077e928

Please sign in to comment.