Skip to content

Commit 4e8106c

Browse files
create profiles go dir if go installed but not exists
1 parent 93ddff5 commit 4e8106c

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

dist/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ function addBinToPath() {
13311331
return __awaiter(this, void 0, void 0, function* () {
13321332
let added = false;
13331333
let g = yield io.which('go');
1334-
core.debug(`which go :${g};`);
1334+
core.debug(`which go :${g}:`);
13351335
if (!g) {
13361336
core.debug('go not in the path');
13371337
return added;
@@ -1340,18 +1340,18 @@ function addBinToPath() {
13401340
if (buf) {
13411341
let gp = buf.toString().trim();
13421342
core.debug(`go env GOPATH :${gp}:`);
1343-
if (fs.existsSync(gp)) {
1344-
let bp = path.join(gp, 'bin');
1345-
if (!fs.existsSync(bp)) {
1346-
core.debug(`creating ${bp}`);
1347-
io.mkdirP(bp);
1348-
}
1349-
core.addPath(bp);
1350-
added = true;
1343+
if (!fs.existsSync(gp)) {
1344+
// some of the hosted images have go install but not profile dir
1345+
core.debug(`creating ${gp}`);
1346+
io.mkdirP(gp);
13511347
}
1352-
else {
1353-
core.debug('go env GOPATH does not exist');
1348+
let bp = path.join(gp, 'bin');
1349+
if (!fs.existsSync(bp)) {
1350+
core.debug(`creating ${bp}`);
1351+
io.mkdirP(bp);
13541352
}
1353+
core.addPath(bp);
1354+
added = true;
13551355
}
13561356
return added;
13571357
});

src/main.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function run() {
6363
async function addBinToPath(): Promise<boolean> {
6464
let added = false;
6565
let g = await io.which('go');
66-
core.debug(`which go :${g};`);
66+
core.debug(`which go :${g}:`);
6767
if (!g) {
6868
core.debug('go not in the path');
6969
return added;
@@ -73,18 +73,20 @@ async function addBinToPath(): Promise<boolean> {
7373
if (buf) {
7474
let gp = buf.toString().trim();
7575
core.debug(`go env GOPATH :${gp}:`);
76-
if (fs.existsSync(gp)) {
77-
let bp = path.join(gp, 'bin');
78-
if (!fs.existsSync(bp)) {
79-
core.debug(`creating ${bp}`);
80-
io.mkdirP(bp);
81-
}
76+
if (!fs.existsSync(gp)) {
77+
// some of the hosted images have go install but not profile dir
78+
core.debug(`creating ${gp}`);
79+
io.mkdirP(gp);
80+
}
8281

83-
core.addPath(bp);
84-
added = true;
85-
} else {
86-
core.debug('go env GOPATH does not exist');
82+
let bp = path.join(gp, 'bin');
83+
if (!fs.existsSync(bp)) {
84+
core.debug(`creating ${bp}`);
85+
io.mkdirP(bp);
8786
}
87+
88+
core.addPath(bp);
89+
added = true;
8890
}
8991
return added;
9092
}

0 commit comments

Comments
 (0)