mirror of
https://code.forgejo.org/actions/setup-go
synced 2025-06-09 03:52:22 +02:00
create bin if not under go env GOPATH
This commit is contained in:
parent
3e014ec8a4
commit
1fea44b3f0
3 changed files with 40 additions and 19 deletions
23
src/main.ts
23
src/main.ts
|
@ -1,4 +1,5 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as installer from './installer';
|
||||
import * as path from 'path';
|
||||
|
@ -59,17 +60,25 @@ export async function run() {
|
|||
}
|
||||
}
|
||||
|
||||
function addBinToPath(): boolean {
|
||||
async function addBinToPath(): Promise<boolean> {
|
||||
let added = false;
|
||||
let g = await io.which('go');
|
||||
if (!g) {
|
||||
core.debug('go not in the path');
|
||||
return added;
|
||||
}
|
||||
|
||||
let buf = cp.execSync('go env GOPATH');
|
||||
|
||||
if (buf) {
|
||||
let d = buf.toString().trim();
|
||||
core.debug(`go env GOPATH: ${d}`);
|
||||
let bp = path.join(d, 'bin');
|
||||
let gp = buf.toString().trim();
|
||||
core.debug(`go env GOPATH: ${gp}`);
|
||||
if (fs.existsSync(gp)) {
|
||||
let bp = path.join(gp, 'bin');
|
||||
if (!fs.existsSync(bp)) {
|
||||
core.debug(`creating ${bp}`);
|
||||
io.mkdirP(bp);
|
||||
}
|
||||
|
||||
if (fs.existsSync(bp)) {
|
||||
core.debug(`${bp} exists`);
|
||||
core.addPath(bp);
|
||||
added = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue