mirror of
				https://github.com/pnpm/action-setup.git
				synced 2025-11-04 05:19:08 +08:00 
			
		
		
		
	Run pnpm store prune post action
This commit is contained in:
		
							
								
								
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -3,12 +3,13 @@ import getInputs from './inputs'
 | 
			
		||||
import setOutputs from './outputs'
 | 
			
		||||
import installPnpm from './install-pnpm'
 | 
			
		||||
import pnpmInstall from './pnpm-install'
 | 
			
		||||
import pruneStore from './pnpm-store-prune'
 | 
			
		||||
 | 
			
		||||
async function main() {
 | 
			
		||||
  const isPost = getState('is_post')
 | 
			
		||||
  if (isPost === 'true') return
 | 
			
		||||
  saveState('is_post', 'true')
 | 
			
		||||
  const inputs = getInputs()
 | 
			
		||||
  const isPost = getState('is_post')
 | 
			
		||||
  if (isPost === 'true') return pruneStore(inputs)
 | 
			
		||||
  saveState('is_post', 'true')
 | 
			
		||||
  await installPnpm(inputs)
 | 
			
		||||
  console.log('Installation Completed!')
 | 
			
		||||
  setOutputs(inputs)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								src/pnpm-store-prune/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/pnpm-store-prune/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
import { spawnSync } from 'child_process'
 | 
			
		||||
import { setFailed } from '@actions/core'
 | 
			
		||||
import { Inputs } from '../inputs'
 | 
			
		||||
 | 
			
		||||
export function pruneStore(inputs: Inputs) {
 | 
			
		||||
  if (inputs.runInstall.length === 0) {
 | 
			
		||||
    console.log('Pruning is unnecessary.')
 | 
			
		||||
    return
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log('Running pnpm store prune')
 | 
			
		||||
  const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
 | 
			
		||||
    stdio: 'inherit',
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  if (error) {
 | 
			
		||||
    setFailed(error)
 | 
			
		||||
    return
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (status) {
 | 
			
		||||
    setFailed(`command pnpm store prune exits with code ${status}`)
 | 
			
		||||
    return
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default pruneStore
 | 
			
		||||
		Reference in New Issue
	
	Block a user