Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 89 additions & 89 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/inputs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ const options: InputOptions = {
required: true,
}

const parseInputPath = (name: string) => expandTilde(getInput(name, options))

function parseRuntime(): RuntimeInput | undefined {
const raw = getInput('runtime').trim()
if (!raw) return undefined
Expand Down Expand Up @@ -128,7 +126,7 @@ function isSupportedRuntime(name: string): name is RuntimeName {

export const getInputs = (): Inputs => ({
version: getInput('version'),
dest: parseInputPath('dest'),
dest: path.resolve(expandTilde(getInput('dest', options))),
cache: getBooleanInput('cache'),
...resolveProjectPaths(),
runtime: parseRuntime(),
Expand Down
7 changes: 2 additions & 5 deletions src/pnpm-install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ export function runPnpmInstall(inputs: Inputs, runtimeInstalled = Boolean(inputs
return
}

// spawnSync inherits process.env, which already has $PNPM_HOME/bin and
// $PNPM_HOME prepended via addPath() in install-pnpm — so the pnpm this
// action installed (or a self-updated one) is the one that resolves.
const pnpmBin = path.join(inputs.dest, process.platform === 'win32' ? 'pnpm.exe' : 'pnpm')
startGroup(`Running ${command}...`)
const { error, status, signal } = spawnSync('pnpm', args, {
const { error, status, signal } = spawnSync(pnpmBin, args, {
stdio: 'inherit',
cwd: workingDirectory,
shell: true,
})
endGroup()

Expand Down
5 changes: 3 additions & 2 deletions src/pnpm-store-prune/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { warning, startGroup, endGroup } from '@actions/core'
import { spawnSync } from 'child_process'
import path from 'path'
import { Inputs } from '../inputs'

export function pruneStore(inputs: Inputs) {
Expand All @@ -9,9 +10,9 @@ export function pruneStore(inputs: Inputs) {
}

startGroup('Running pnpm store prune...')
const { error, status } = spawnSync('pnpm', ['store', 'prune'], {
const pnpmBin = path.join(inputs.dest, process.platform === 'win32' ? 'pnpm.exe' : 'pnpm')
const { error, status } = spawnSync(pnpmBin, ['store', 'prune'], {
Comment on lines +13 to +14

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Pruning bypasses updated pnpm

If a later workflow step runs pnpm self-update, the replacement in dest/bin takes precedence on PATH. This absolute path instead runs the original dest/pnpm during the post action, so cache cleanup may use different store-pruning behavior than the pnpm version used by the rest of the job. Preserve the prepared dest/bin precedence without reintroducing shell execution.

Knowledge Base Used:

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

stdio: 'inherit',
shell: true,
})
endGroup()

Expand Down
Loading