mirror of
https://github.com/pnpm/action-setup.git
synced 2025-07-18 13:39:04 +08:00
Create some files
This commit is contained in:
17
src/install/index.ts
Normal file
17
src/install/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { setFailed } from '@actions/core'
|
||||
import { getInputs } from '../inputs'
|
||||
import runSelfInstaller from './run'
|
||||
|
||||
export { runSelfInstaller }
|
||||
|
||||
export async function install() {
|
||||
const { error, status } = await runSelfInstaller(getInputs())
|
||||
|
||||
if (error) return setFailed(error)
|
||||
|
||||
if (status) {
|
||||
return setFailed(`Something does wrong, self-installer exits with code ${status}`)
|
||||
}
|
||||
}
|
||||
|
||||
export default install
|
18
src/install/run.ts
Normal file
18
src/install/run.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { spawnSync } from 'child_process'
|
||||
import { downloadSelfInstaller } from '../self-installer'
|
||||
import { Inputs } from '../inputs'
|
||||
|
||||
export async function runSelfInstaller(inputs: Inputs) {
|
||||
return spawnSync('node', {
|
||||
env: {
|
||||
PNPM_VERSION: inputs.version,
|
||||
PNPM_DEST: inputs.dest,
|
||||
PNPM_BIN_DEST: inputs.binDest,
|
||||
PNPM_REGISTRY: inputs.registry,
|
||||
},
|
||||
input: await downloadSelfInstaller(),
|
||||
stdio: 'inherit',
|
||||
})
|
||||
}
|
||||
|
||||
export default runSelfInstaller
|
Reference in New Issue
Block a user