mirror of
https://github.com/pnpm/action-setup.git
synced 2024-12-23 00:06:30 +08:00
Complete basic
This commit is contained in:
parent
21f3fd8b57
commit
7d62586afe
12
src/index.ts
Normal file
12
src/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { setFailed } from '@actions/core'
|
||||||
|
import getInputs from './inputs'
|
||||||
|
import install from './install'
|
||||||
|
|
||||||
|
const inputs = getInputs()
|
||||||
|
|
||||||
|
install(inputs).then(() => {
|
||||||
|
console.log('Installation Completed!')
|
||||||
|
}).catch(error => {
|
||||||
|
console.error(error)
|
||||||
|
setFailed(error)
|
||||||
|
})
|
|
@ -1,14 +1,11 @@
|
||||||
import { setFailed } from '@actions/core'
|
import { setFailed } from '@actions/core'
|
||||||
import getInputs from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import runSelfInstaller from './run'
|
import runSelfInstaller from './run'
|
||||||
|
|
||||||
export { runSelfInstaller }
|
export { runSelfInstaller }
|
||||||
|
|
||||||
export async function install() {
|
export async function install(inputs: Inputs) {
|
||||||
const { error, status } = await runSelfInstaller(getInputs())
|
const status = await runSelfInstaller(inputs)
|
||||||
|
|
||||||
if (error) return setFailed(error)
|
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
return setFailed(`Something does wrong, self-installer exits with code ${status}`)
|
return setFailed(`Something does wrong, self-installer exits with code ${status}`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
import { spawnSync } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { downloadSelfInstaller } from '../self-installer'
|
import { downloadSelfInstaller } from '../self-installer'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
export async function runSelfInstaller(inputs: Inputs) {
|
export function runSelfInstaller(inputs: Inputs): Promise<number> {
|
||||||
return spawnSync('node', {
|
const cp = spawn('node', {
|
||||||
env: {
|
env: {
|
||||||
PNPM_VERSION: inputs.version,
|
PNPM_VERSION: inputs.version,
|
||||||
PNPM_DEST: inputs.dest,
|
PNPM_DEST: inputs.dest,
|
||||||
PNPM_BIN_DEST: inputs.binDest,
|
PNPM_BIN_DEST: inputs.binDest,
|
||||||
PNPM_REGISTRY: inputs.registry,
|
PNPM_REGISTRY: inputs.registry,
|
||||||
},
|
},
|
||||||
input: await downloadSelfInstaller(),
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
stdio: 'inherit',
|
})
|
||||||
|
|
||||||
|
downloadSelfInstaller().pipe(cp.stdin)
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
cp.on('error', reject)
|
||||||
|
cp.on('close', resolve)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user