@@ -15,24 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
1515} ) : function ( o , v ) {
1616 o [ "default" ] = v ;
1717} ) ;
18- var __importStar = ( this && this . __importStar ) || function ( mod ) {
19- if ( mod && mod . __esModule ) return mod ;
20- var result = { } ;
21- if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
22- __setModuleDefault ( result , mod ) ;
23- return result ;
24- } ;
25- var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
26- function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
27- return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
28- function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
29- function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
30- function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
31- step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
32- } ) ;
33- } ;
18+ var __importStar = ( this && this . __importStar ) || ( function ( ) {
19+ var ownKeys = function ( o ) {
20+ ownKeys = Object . getOwnPropertyNames || function ( o ) {
21+ var ar = [ ] ;
22+ for ( var k in o ) if ( Object . prototype . hasOwnProperty . call ( o , k ) ) ar [ ar . length ] = k ;
23+ return ar ;
24+ } ;
25+ return ownKeys ( o ) ;
26+ } ;
27+ return function ( mod ) {
28+ if ( mod && mod . __esModule ) return mod ;
29+ var result = { } ;
30+ if ( mod != null ) for ( var k = ownKeys ( mod ) , i = 0 ; i < k . length ; i ++ ) if ( k [ i ] !== "default" ) __createBinding ( result , mod , k [ i ] ) ;
31+ __setModuleDefault ( result , mod ) ;
32+ return result ;
33+ } ;
34+ } ) ( ) ;
3435Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
35- exports . cleanup = exports . execer = void 0 ;
36+ exports . execer = void 0 ;
37+ exports . cleanup = cleanup ;
3638const core = __importStar ( require ( "@actions/core" ) ) ;
3739const cp = __importStar ( require ( "child_process" ) ) ;
3840const fs = __importStar ( require ( "fs" ) ) ;
@@ -43,56 +45,51 @@ const tc = __importStar(require("@actions/tool-cache"));
4345const util = __importStar ( require ( "util" ) ) ;
4446const state_helper_1 = require ( "./state-helper" ) ;
4547exports . execer = util . promisify ( cp . exec ) ;
46- function run ( ) {
47- return __awaiter ( this , void 0 , void 0 , function * ( ) {
48- try {
49- //
50- // Version is optional. If supplied, install / use from the tool cache
51- // If not supplied then task is still used to setup proxy, auth, etc...
52- //
53- const version = resolveVersionInput ( ) ;
54- let arch = core . getInput ( 'architecture' ) ;
55- // if architecture supplied but version is not
56- // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
57- if ( arch && ! version ) {
58- core . warning ( '`architecture` is provided but `version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `version`' ) ;
59- }
60- if ( ! arch ) {
61- arch = os . arch ( ) ;
62- }
63- const token = core . getInput ( 'token' , { required : true } ) ;
64- const stable = strToBoolean ( core . getInput ( 'stable' ) || 'false' ) ;
65- const checkLatest = strToBoolean ( core . getInput ( 'check-latest' ) || 'false' ) ;
66- const binPath = yield installer . getVlang ( {
67- authToken : token ,
68- version,
69- checkLatest,
70- stable,
71- arch
72- } ) ;
73- core . info ( 'Adding v to the cache...' ) ;
74- const installedVersion = yield getVersion ( binPath ) ;
75- const cachedPath = yield tc . cacheDir ( binPath , 'v' , installedVersion ) ;
76- core . info ( `Cached v to: ${ cachedPath } ` ) ;
77- core . addPath ( cachedPath ) ;
78- const vBinPath = path . join ( binPath , 'v' ) ;
79- core . setOutput ( 'bin-path' , binPath ) ;
80- core . setOutput ( 'v-bin-path' , vBinPath ) ;
81- core . setOutput ( 'version' , installedVersion ) ;
82- core . setOutput ( 'architecture' , arch ) ;
48+ async function run ( ) {
49+ try {
50+ //
51+ // Version is optional. If supplied, install / use from the tool cache
52+ // If not supplied then task is still used to setup proxy, auth, etc...
53+ //
54+ const version = resolveVersionInput ( ) ;
55+ let arch = core . getInput ( 'architecture' ) ;
56+ // if architecture supplied but version is not
57+ // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
58+ if ( arch && ! version ) {
59+ core . warning ( '`architecture` is provided but `version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `version`' ) ;
8360 }
84- catch ( error ) {
85- if ( error instanceof Error )
86- core . setFailed ( error . message ) ;
61+ if ( ! arch ) {
62+ arch = os . arch ( ) ;
8763 }
88- } ) ;
64+ const token = core . getInput ( 'token' , { required : true } ) ;
65+ const stable = strToBoolean ( core . getInput ( 'stable' ) || 'false' ) ;
66+ const checkLatest = strToBoolean ( core . getInput ( 'check-latest' ) || 'false' ) ;
67+ const binPath = await installer . getVlang ( {
68+ authToken : token ,
69+ version,
70+ checkLatest,
71+ stable,
72+ arch
73+ } ) ;
74+ core . info ( 'Adding v to the cache...' ) ;
75+ const installedVersion = await getVersion ( binPath ) ;
76+ const cachedPath = await tc . cacheDir ( binPath , 'v' , installedVersion ) ;
77+ core . info ( `Cached v to: ${ cachedPath } ` ) ;
78+ core . addPath ( cachedPath ) ;
79+ const vBinPath = path . join ( binPath , 'v' ) ;
80+ core . setOutput ( 'bin-path' , binPath ) ;
81+ core . setOutput ( 'v-bin-path' , vBinPath ) ;
82+ core . setOutput ( 'version' , installedVersion ) ;
83+ core . setOutput ( 'architecture' , arch ) ;
84+ }
85+ catch ( error ) {
86+ if ( error instanceof Error )
87+ core . setFailed ( error . message ) ;
88+ }
8989}
90- function cleanup ( ) {
91- return __awaiter ( this , void 0 , void 0 , function * ( ) {
92- // @todo : implement
93- } ) ;
90+ async function cleanup ( ) {
91+ // @todo : implement
9492}
95- exports . cleanup = cleanup ;
9693function resolveVersionInput ( ) {
9794 let version = core . getInput ( 'version' ) ;
9895 const versionFileInput = core . getInput ( 'version-file' ) ;
@@ -121,19 +118,17 @@ function strToBoolean(str) {
121118 const falsyValues = [ 'false' , 'no' , '0' , '' , 'undefined' , 'null' ] ;
122119 return ! falsyValues . includes ( str . toLowerCase ( ) ) ;
123120}
124- function getVersion ( binPath ) {
125- return __awaiter ( this , void 0 , void 0 , function * ( ) {
126- const vBinPath = path . join ( binPath , 'v' ) ;
127- const { stdout, stderr } = yield ( 0 , exports . execer ) ( `${ vBinPath } version` ) ;
128- if ( stderr !== '' ) {
129- throw new Error ( `Unable to get version from ${ vBinPath } ` ) ;
130- }
131- if ( stdout !== '' ) {
132- return stdout . trim ( ) . split ( ' ' ) [ 1 ] ;
133- }
134- core . warning ( 'Unable to get version from v executable.' ) ;
135- return '0.0.0' ;
136- } ) ;
121+ async function getVersion ( binPath ) {
122+ const vBinPath = path . join ( binPath , 'v' ) ;
123+ const { stdout, stderr } = await ( 0 , exports . execer ) ( `${ vBinPath } version` ) ;
124+ if ( stderr !== '' ) {
125+ throw new Error ( `Unable to get version from ${ vBinPath } ` ) ;
126+ }
127+ if ( stdout !== '' ) {
128+ return stdout . trim ( ) . split ( ' ' ) [ 1 ] ;
129+ }
130+ core . warning ( 'Unable to get version from v executable.' ) ;
131+ return '0.0.0' ;
137132}
138133if ( state_helper_1 . IS_POST ) {
139134 cleanup ( ) ;
0 commit comments