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 5 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
11 changes: 7 additions & 4 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ 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.
cp.execFileSync(goRuntimePath, ['mod', 'tidy'], opts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we do this only if modulesOff is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (err) {
outputChannel.appendLine('Installing ' + getImportPath(tool, goVersion) + ' FAILED');
const failureReason = tool.name + ';;' + err + stdout.toString() + stderr.toString();
Expand Down Expand Up @@ -188,10 +195,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