Fix pruneStore

This commit is contained in:
khai96_ 2020-05-09 21:41:25 +07:00
parent 2546768411
commit b1febf84ed
4 changed files with 13 additions and 6 deletions

BIN
dist/index.js vendored

Binary file not shown.

View File

@ -1,14 +1,10 @@
import process from 'process'
import path from 'path'
import { spawnSync } from 'child_process' import { spawnSync } from 'child_process'
import { setFailed } from '@actions/core' import { setFailed } from '@actions/core'
import { Inputs } from '../inputs' import { Inputs } from '../inputs'
import { patchPnpmEnv } from '../utils'
export function runPnpmInstall(inputs: Inputs) { export function runPnpmInstall(inputs: Inputs) {
const env = { const env = patchPnpmEnv(inputs)
...process.env,
PATH: inputs.binDest + path.delimiter + process.env.PATH
}
for (const options of inputs.runInstall) { for (const options of inputs.runInstall) {
const args = ['install'] const args = ['install']

View File

@ -1,6 +1,7 @@
import { spawnSync } from 'child_process' import { spawnSync } from 'child_process'
import { setFailed } from '@actions/core' import { setFailed } from '@actions/core'
import { Inputs } from '../inputs' import { Inputs } from '../inputs'
import { patchPnpmEnv } from '../utils'
export function pruneStore(inputs: Inputs) { export function pruneStore(inputs: Inputs) {
if (inputs.runInstall.length === 0) { if (inputs.runInstall.length === 0) {
@ -11,6 +12,8 @@ export function pruneStore(inputs: Inputs) {
console.log('Running pnpm store prune') console.log('Running pnpm store prune')
const { error, status } = spawnSync('pnpm', ['store', 'prune'], { const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
stdio: 'inherit', stdio: 'inherit',
shell: true,
env: patchPnpmEnv(inputs)
}) })
if (error) { if (error) {

8
src/utils/index.ts Normal file
View File

@ -0,0 +1,8 @@
import process from 'process'
import path from 'path'
import { Inputs } from '../inputs'
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
...process.env,
PATH: inputs.binDest + path.delimiter + process.env.PATH
})