mirror of
				https://github.com/actions/setup-go.git
				synced 2025-10-30 23:06:22 +00:00 
			
		
		
		
	add bin to path
This commit is contained in:
		| @@ -1,9 +1,12 @@ | ||||
| import * as tc from '@actions/tool-cache'; | ||||
| import * as cm from '@actions/core'; | ||||
| import * as path from 'path'; | ||||
| import * as semver from 'semver'; | ||||
| import * as httpm from '@actions/http-client'; | ||||
| import * as sys from './system'; | ||||
| import {debug} from '@actions/core'; | ||||
| import * as cp from 'child_process'; | ||||
| import * as fs from 'fs'; | ||||
|  | ||||
| export async function downloadGo( | ||||
|   versionSpec: string, | ||||
| @@ -34,6 +37,8 @@ export async function downloadGo( | ||||
|       // extracts with a root folder that matches the fileName downloaded | ||||
|       const toolRoot = path.join(extPath, 'go'); | ||||
|       toolPath = await tc.cacheDir(toolRoot, 'go', makeSemver(match.version)); | ||||
|  | ||||
|       addBinToPath(); | ||||
|     } | ||||
|   } catch (error) { | ||||
|     throw new Error(`Failed to download version ${versionSpec}: ${error}`); | ||||
| @@ -55,6 +60,17 @@ export interface IGoVersion { | ||||
|   files: IGoVersionFile[]; | ||||
| } | ||||
|  | ||||
| export async function addBinToPath() { | ||||
|   let buf = cp.execSync('go env GOPATH'); | ||||
|   if (buf) { | ||||
|     let d = buf.toString().trim(); | ||||
|     let bp = path.join(d, 'bin'); | ||||
|     if (fs.existsSync(bp)) { | ||||
|       cm.addPath(bp); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| export async function findMatch( | ||||
|   versionSpec: string, | ||||
|   stable: boolean | ||||
|   | ||||
		Reference in New Issue
	
	Block a user