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

run go mod tidy between tool installations #2877

Merged
merged 6 commits into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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