mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
gobin: make sure GOPATH gets trimmed before use in path.join
On Windows, `go env GOPATH` keeps the end-line character, making it unusable (see sample build failure: https://github.com/fsouza/vod-module-sprite/runs/478762225?check_suite_focus=true#step:5:62).
This commit is contained in:
parent
4241f446d8
commit
5a59f896b9
3 changed files with 10 additions and 2 deletions
|
@ -20,4 +20,12 @@ describe('gobin', () => {
|
||||||
const gobinPath = await gobin.getGOBIN('...');
|
const gobinPath = await gobin.getGOBIN('...');
|
||||||
expect(gobinPath).toBe(path.join(gopath, 'bin'));
|
expect(gobinPath).toBe(path.join(gopath, 'bin'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should trim ${GOPATH} before using it', async () => {
|
||||||
|
let trimmed = gopath;
|
||||||
|
gopath = `${gopath}\r\n`;
|
||||||
|
|
||||||
|
const gobinPath = await gobin.getGOBIN('...');
|
||||||
|
expect(gobinPath).toBe(path.join(trimmed, 'bin'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
|
@ -3280,7 +3280,7 @@ function getGOBIN(installDir) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const goExecutable = path.join(installDir, 'bin', 'go');
|
const goExecutable = path.join(installDir, 'bin', 'go');
|
||||||
const result = yield execFile(goExecutable, ['env', 'GOPATH']);
|
const result = yield execFile(goExecutable, ['env', 'GOPATH']);
|
||||||
const gopath = result.stdout;
|
const gopath = result.stdout.replace(/\s+$/, '');
|
||||||
return path.join(gopath, 'bin');
|
return path.join(gopath, 'bin');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,6 @@ export async function getGOBIN(installDir: string): Promise<string> {
|
||||||
const goExecutable = path.join(installDir, 'bin', 'go');
|
const goExecutable = path.join(installDir, 'bin', 'go');
|
||||||
|
|
||||||
const result = await execFile(goExecutable, ['env', 'GOPATH']);
|
const result = await execFile(goExecutable, ['env', 'GOPATH']);
|
||||||
const gopath = result.stdout;
|
const gopath = result.stdout.replace(/\s+$/, '');
|
||||||
return path.join(gopath, 'bin');
|
return path.join(gopath, 'bin');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue