setup-go/src/gobin.ts
francisco souza 5a59f896b9
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).
2020-03-01 23:59:03 -05:00

13 lines
447 B
TypeScript

import * as childProcess from 'child_process';
import * as path from 'path';
import {promisify} from 'util';
const execFile = promisify(childProcess.execFile);
export async function getGOBIN(installDir: string): Promise<string> {
const goExecutable = path.join(installDir, 'bin', 'go');
const result = await execFile(goExecutable, ['env', 'GOPATH']);
const gopath = result.stdout.replace(/\s+$/, '');
return path.join(gopath, 'bin');
}