From 1790ca7f76c4c79099196814f87470ca68fcda4d Mon Sep 17 00:00:00 2001 From: khai96_ Date: Sat, 9 May 2020 20:24:52 +0700 Subject: [PATCH] Add pnpm install --- dist/index.js | Bin 210346 -> 211153 bytes src/index.ts | 2 ++ src/pnpm-install/index.ts | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 src/pnpm-install/index.ts diff --git a/dist/index.js b/dist/index.js index 83e7641cdce7c59997033d2b681a0ad722558ab4..e3600f06482727adc6ebc7debf736e0208e8ca00 100644 GIT binary patch delta 1846 zcmZ`)Yitx%6wbY+0i;S>EK5;fI)yURnGUq3h`YTgcC^EzV_RAVElt?&-tCS~XP0@j zwcAO9F+QR($`Ws=NQj~Sz(1OTlR`A`%g}~L6B7d_8c2+gCJH~$L7WCeR(tll(Es!hhUk81|xcc)A&qZ)MDDjCR9@^?m}9&xjY24EG~b! zKo-^PnexzDwIRu8Wb{g>Dxlh~h$SGF85&|(!IWGZw?rKWTP7!u-7WuR(LAN9N*TMh z=1w7yv%dtH?RMjVG&dtQ z3+xapq?*X0rMOc#Bf_;smG!D!Fh1R2R#_j2C)2 z%nGW%@N4iDER(4#_I`+?7+HT3Y$nCyVAsR(6=Y-_?0Y!==Kn+f*^^)l(&BsHfMiif zL0g2{V0Kz-tW9kkXV)0~I)x_{-+}Uy;E=DT#Ye4?d^f5lz!uuS^aOZ(xrQ9e#rct= z110rE4HpNlWO8@{u#04btURic$qDdOsoJoU&vaWj`kEJbiz1a2Pl8HTMQvPk-8SCC zQrfkX+#uJ;sp5K`=OaC6FK37f>6irdbWq-#1g9UR<=uV>+@L9-%b;*RrPFu?kP?mO zGbS=63#W}}40D=4eFfYtqFtE&4YbidZ~7g4uz<>Qe}blYi)6`;C2=qALbAW=A5i@% zR1m39;gYhgL2J8(nVI7ljxL8r;-k)EsgGeL z89oe`6Eq5|C}nEbu@u&CBqh(m)miV>yW|ZClnz^5g4KcxO%|5YZbGs5YrEcAn zvF!-n;gqf z<;b;n+6UG%Ww2$Xtgs={syMD4wmsA*+39G%x#M*+#?AON#fcjWXTCwvO#D?8to%@+<~KHDHlM@`EgLzoY>qcdGv9 zm*5X2i}OR6M!}LiO;=}d8rm?D_ODLE(WUgO+;(4bjdWS5+xGt^r!}EXGb_%IPJ2Kr&v@Q}Ed);l$DS97ls_CZd=X_3`+JnVn3zLe4-ixL zK2t*#)jaR@Y*+geQl8>xqpFO1_6H3a3%)|ZC&;NlE~D>`WwW}G5^4FC_ow<=t)oLL zFSp-x05yM>+nOj&rlOhD+D-eVEFOtcbDJ{9@kd(i_^e0$>-konT;^TPB5Xy$`ATG`MfxXh<+I2<-DVfRe}b!k;~f=r5fGNb3& zO$PT{Z%jhm!In$lW`9mW2q+sKM%($*t5+4iSbPQTUL#Sht0g!JHL5I_AUCpik3%D< z*35Bm*YaqcgfmdbL0{1)6wUgs7SnaP)_VOE;D%leXL50UJT0z=0a+*ra$1rFS&$TR z8y%8`ef!#b`vh5IzkdRL(AYz>@ETX~!7Q|a%D$e3P8XHeS@_{c1zEK=ehMF>Cd#RV zJ0X!{ta}aynCmR;y*s{@mCnMecgK(XKV*G52W7Z982bOn~JjOc@XL; z#zqxY*}^=&JlBD1$ zJ|rd;jg2foA8(bn7U1)HxV^i+gI{?H_!2laa5fnO;t&wKy{5f=_ zp%7?HPCDxCQn$_Na0Ig__0RR91 diff --git a/src/index.ts b/src/index.ts index 8add39b..4273417 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,12 +2,14 @@ import { setFailed } from '@actions/core' import getInputs from './inputs' import setOutputs from './outputs' import installPnpm from './install-pnpm' +import pnpmInstall from './pnpm-install' async function main() { const inputs = getInputs() await installPnpm(inputs) console.log('Installation Completed!') setOutputs(inputs) + pnpmInstall(inputs) } main().catch(error => { diff --git a/src/pnpm-install/index.ts b/src/pnpm-install/index.ts new file mode 100644 index 0000000..5a09a0d --- /dev/null +++ b/src/pnpm-install/index.ts @@ -0,0 +1,40 @@ +import process from 'process' +import path from 'path' +import { spawnSync } from 'child_process' +import { setFailed } from '@actions/core' +import { Inputs } from '../inputs' + +export function runPnpmInstall(inputs: Inputs) { + const env = { + ...process.env, + PATH: inputs.binDest + path.delimiter + process.env.PATH + } + + for (const options of inputs.runInstall) { + const args = ['install'] + if (options.recursive) args.unshift('recursive') + if (options.args) args.push(...options.args) + + const cmdStr = ['pnpm', ...args].join(' ') + console.log('Running', cmdStr) + + const { error, status } = spawnSync('pnpm', args, { + stdio: 'inherit', + cwd: options.cwd, + shell: true, + env, + }) + + if (error) { + setFailed(error) + continue + } + + if (status) { + setFailed(`Command ${cmdStr} (cwd: ${options.cwd}) exits with status ${status}`) + continue + } + } +} + +export default runPnpmInstall