From 4e8106ca18379285c4888d56766be9a43eddfb3e Mon Sep 17 00:00:00 2001 From: Bryan MacFarlane Date: Thu, 26 Mar 2020 13:00:45 -0400 Subject: [PATCH] create profiles go dir if go installed but not exists --- dist/index.js | 22 +++++++++++----------- src/main.ts | 26 ++++++++++++++------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/dist/index.js b/dist/index.js index bc33c82..2414b9b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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; @@ -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; }); diff --git a/src/main.ts b/src/main.ts index 3dbba07..887d72f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -63,7 +63,7 @@ export async function run() { async function addBinToPath(): Promise { 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; @@ -73,18 +73,20 @@ async function addBinToPath(): Promise { 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; - } else { - core.debug('go env GOPATH does not exist'); + if (!fs.existsSync(gp)) { + // some of the hosted images have go install but not profile dir + core.debug(`creating ${gp}`); + io.mkdirP(gp); } + + let bp = path.join(gp, 'bin'); + if (!fs.existsSync(bp)) { + core.debug(`creating ${bp}`); + io.mkdirP(bp); + } + + core.addPath(bp); + added = true; } return added; }