mirror of
https://github.com/pnpm/action-setup.git
synced 2026-08-14 22:12:09 +08:00
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.
46 lines
1.2 KiB
TypeScript
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)
|
|
})
|