mirror of
https://github.com/pnpm/action-setup.git
synced 2026-04-05 20:20:48 +08:00
Compare commits
2 Commits
fix-window
...
dev-engine
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7133229bf3 | ||
|
|
cf8555bd12 |
36
.github/workflows/test.yaml
vendored
36
.github/workflows/test.yaml
vendored
@@ -33,14 +33,7 @@ jobs:
|
|||||||
run: which pnpm; which pnpx
|
run: which pnpm; which pnpx
|
||||||
|
|
||||||
- name: 'Test: version'
|
- name: 'Test: version'
|
||||||
run: |
|
run: pnpm --version
|
||||||
actual="$(pnpm --version)"
|
|
||||||
echo "pnpm version: ${actual}"
|
|
||||||
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
||||||
echo "ERROR: pnpm --version did not produce valid output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: 'Test: install in a fresh project'
|
- name: 'Test: install in a fresh project'
|
||||||
run: |
|
run: |
|
||||||
@@ -78,14 +71,7 @@ jobs:
|
|||||||
run: which pnpm && which pnpx
|
run: which pnpm && which pnpx
|
||||||
|
|
||||||
- name: 'Test: version'
|
- name: 'Test: version'
|
||||||
run: |
|
run: pnpm --version
|
||||||
actual="$(pnpm --version)"
|
|
||||||
echo "pnpm version: ${actual}"
|
|
||||||
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
||||||
echo "ERROR: pnpm --version did not produce valid output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
test_standalone:
|
test_standalone:
|
||||||
name: Test with standalone
|
name: Test with standalone
|
||||||
@@ -112,14 +98,7 @@ jobs:
|
|||||||
run: which pnpm
|
run: which pnpm
|
||||||
|
|
||||||
- name: 'Test: version'
|
- name: 'Test: version'
|
||||||
run: |
|
run: pnpm --version
|
||||||
actual="$(pnpm --version)"
|
|
||||||
echo "pnpm version: ${actual}"
|
|
||||||
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
||||||
echo "ERROR: pnpm --version did not produce valid output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: 'Test: install in a fresh project'
|
- name: 'Test: install in a fresh project'
|
||||||
run: |
|
run: |
|
||||||
@@ -217,11 +196,4 @@ jobs:
|
|||||||
run: which pnpm; which pnpx
|
run: which pnpm; which pnpx
|
||||||
|
|
||||||
- name: 'Test: version'
|
- name: 'Test: version'
|
||||||
run: |
|
run: pnpm --version
|
||||||
actual="$(pnpm --version)"
|
|
||||||
echo "pnpm version: ${actual}"
|
|
||||||
if [[ ! "${actual}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
|
||||||
echo "ERROR: pnpm --version did not produce valid output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|||||||
222
dist/index.js
vendored
222
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -34,33 +34,23 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
return npmExitCode
|
return npmExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows with standalone mode, npm's .bin shims can't properly
|
const pnpmHome = path.join(dest, 'node_modules', '.bin')
|
||||||
// execute the extensionless @pnpm/exe native binaries. Add the
|
|
||||||
// @pnpm/exe directory directly to PATH so pnpm.exe is found natively.
|
|
||||||
const pnpmHome = standalone && process.platform === 'win32'
|
|
||||||
? path.join(dest, 'node_modules', '@pnpm', 'exe')
|
|
||||||
: path.join(dest, 'node_modules', '.bin')
|
|
||||||
// pnpm expects PNPM_HOME/bin in PATH for global binaries (e.g. node
|
|
||||||
// installed via `pnpm runtime`). Add it first so the next addPath
|
|
||||||
// (pnpmHome itself, which contains pnpm.exe) has higher precedence.
|
|
||||||
addPath(path.join(pnpmHome, 'bin'))
|
|
||||||
addPath(pnpmHome)
|
addPath(pnpmHome)
|
||||||
|
addPath(path.join(pnpmHome, 'bin'))
|
||||||
exportVariable('PNPM_HOME', pnpmHome)
|
exportVariable('PNPM_HOME', pnpmHome)
|
||||||
|
|
||||||
// Ensure pnpm bin link exists — npm ci sometimes doesn't create it
|
// Ensure pnpm bin link exists — npm ci sometimes doesn't create it
|
||||||
if (process.platform !== 'win32') {
|
const pnpmBinLink = path.join(pnpmHome, 'pnpm')
|
||||||
const pnpmBinLink = path.join(dest, 'node_modules', '.bin', 'pnpm')
|
if (!existsSync(pnpmBinLink)) {
|
||||||
if (!existsSync(pnpmBinLink)) {
|
await mkdir(pnpmHome, { recursive: true })
|
||||||
await mkdir(path.join(dest, 'node_modules', '.bin'), { recursive: true })
|
const target = standalone
|
||||||
const target = standalone
|
? path.join('..', '@pnpm', 'exe', 'pnpm')
|
||||||
? path.join('..', '@pnpm', 'exe', 'pnpm')
|
: path.join('..', 'pnpm', 'bin', 'pnpm.mjs')
|
||||||
: path.join('..', 'pnpm', 'bin', 'pnpm.mjs')
|
await symlink(target, pnpmBinLink)
|
||||||
await symlink(target, pnpmBinLink)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bootstrapPnpm = standalone
|
const bootstrapPnpm = standalone
|
||||||
? path.join(dest, 'node_modules', '@pnpm', 'exe', process.platform === 'win32' ? 'pnpm.exe' : 'pnpm')
|
? path.join(dest, 'node_modules', '@pnpm', 'exe', 'pnpm')
|
||||||
: path.join(dest, 'node_modules', 'pnpm', 'bin', 'pnpm.mjs')
|
: path.join(dest, 'node_modules', 'pnpm', 'bin', 'pnpm.mjs')
|
||||||
|
|
||||||
// Determine the target version
|
// Determine the target version
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { setOutput } from '@actions/core'
|
import { setOutput, addPath } from '@actions/core'
|
||||||
import { Inputs } from '../inputs'
|
import { Inputs } from '../inputs'
|
||||||
import { getBinDest } from '../utils'
|
import { getBinDest } from '../utils'
|
||||||
|
|
||||||
export function setOutputs(inputs: Inputs) {
|
export function setOutputs(inputs: Inputs) {
|
||||||
const binDest = getBinDest(inputs)
|
const binDest = getBinDest(inputs)
|
||||||
// NOTE: addPath is already called in installPnpm — do not call it again
|
addPath(binDest)
|
||||||
// here, as a second addPath would shadow the correct entry on Windows.
|
|
||||||
setOutput('dest', inputs.dest)
|
setOutput('dest', inputs.dest)
|
||||||
setOutput('bin_dest', binDest)
|
setOutput('bin_dest', binDest)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user