Files
setup-pnpm/src/index.ts
T
Zoltan Kochan 544072d0b9 docs: tighten the verification cache comments
The module header explained the whole feature where naming the file's purpose
is enough, and the ordering comment described `pnpm store prune` deleting the
log without saying which versions do — pnpm/pnpm#13893 stops deleting it.
2026-08-13 16:47:45 +02:00

46 lines
1.2 KiB
TypeScript

import { setFailed, saveState, getState } from '@actions/core'
import restoreCache from './cache-restore'
import saveCache from './cache-save'
import getInputs, { Inputs } from './inputs'
import installPnpm from './install-pnpm'
import { saveVerificationCache } from './lockfile-verification-cache'
import setOutputs from './outputs'
import pnpmInstall from './pnpm-install'
import pruneStore from './pnpm-store-prune'
async function main() {
if (getState('is_post') === 'true') {
await runPost()
} else {
await runMain()
}
}
async function runMain() {
const inputs = getInputs()
saveState('inputs', inputs)
saveState('is_post', 'true')
const binDest = await installPnpm(inputs)
if (binDest === undefined) return
console.log('Installation Completed!')
setOutputs(inputs, binDest)
await restoreCache(inputs)
pnpmInstall(inputs)
}
async function runPost() {
const inputs = JSON.parse(getState('inputs')) as Inputs
// pnpm versions before pnpm/pnpm#13893 delete the log during a store prune.
await saveVerificationCache()
pruneStore(inputs)
await saveCache(inputs)
}
main().catch(error => {
console.error(error)
setFailed(error)
})