Skip to content

Commit

Permalink
create profiles go dir if go installed but not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan MacFarlane committed Mar 26, 2020
1 parent 93ddff5 commit 4e8106c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
22 changes: 11 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ function addBinToPath() {
return __awaiter(this, void 0, void 0, function* () {
let added = false;
let g = yield io.which('go');
core.debug(`which go :${g};`);
core.debug(`which go :${g}:`);
if (!g) {
core.debug('go not in the path');
return added;
Expand All @@ -1340,18 +1340,18 @@ function addBinToPath() {
if (buf) {
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);
}
core.addPath(bp);
added = true;
if (!fs.existsSync(gp)) {
// some of the hosted images have go install but not profile dir
core.debug(`creating ${gp}`);
io.mkdirP(gp);
}
else {
core.debug('go env GOPATH does not exist');
let bp = path.join(gp, 'bin');
if (!fs.existsSync(bp)) {
core.debug(`creating ${bp}`);
io.mkdirP(bp);
}
core.addPath(bp);
added = true;
}
return added;
});
Expand Down
24 changes: 13 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function run() {
async function addBinToPath(): Promise<boolean> {
let added = false;
let g = await io.which('go');
core.debug(`which go :${g};`);
core.debug(`which go :${g}:`);
if (!g) {
core.debug('go not in the path');
return added;
Expand All @@ -73,18 +73,20 @@ async function addBinToPath(): Promise<boolean> {
if (buf) {
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(gp)) {
// some of the hosted images have go install but not profile dir
core.debug(`creating ${gp}`);
io.mkdirP(gp);
}

core.addPath(bp);
added = true;
} else {
core.debug('go env GOPATH does not exist');
let bp = path.join(gp, 'bin');
if (!fs.existsSync(bp)) {
core.debug(`creating ${bp}`);
io.mkdirP(bp);
}

core.addPath(bp);
added = true;
}
return added;
}

0 comments on commit 4e8106c

Please sign in to comment.