mirror of
https://github.com/pnpm/action-setup.git
synced 2026-03-21 00:13:31 +08:00
Compare commits
1 Commits
dev-engine
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e223e0f0d |
28
.github/workflows/pr-check.yaml
vendored
Normal file
28
.github/workflows/pr-check.yaml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: pr-check
|
||||||
|
|
||||||
|
on: [ pull_request ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-dist:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
|
||||||
|
with:
|
||||||
|
run_install: true
|
||||||
|
version: 9
|
||||||
|
|
||||||
|
- name: Update dist/index.js
|
||||||
|
run: pnpm run build
|
||||||
|
|
||||||
|
- name: Check for uncommitted changes in dist
|
||||||
|
run: git diff --exit-code dist/index.js
|
||||||
8
dist/index.js
vendored
8
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -57,28 +57,21 @@ async function readTarget(opts: {
|
|||||||
const { version, packageJsonFile, standalone } = opts
|
const { version, packageJsonFile, standalone } = opts
|
||||||
const { GITHUB_WORKSPACE } = process.env
|
const { GITHUB_WORKSPACE } = process.env
|
||||||
|
|
||||||
let packageManager: string | undefined
|
let packageManager
|
||||||
let devEngines: { packageManager?: { name?: string; version?: string } } | undefined
|
|
||||||
|
|
||||||
if (GITHUB_WORKSPACE) {
|
if (GITHUB_WORKSPACE) {
|
||||||
try {
|
try {
|
||||||
const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
|
const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8');
|
||||||
const manifest = packageJsonFile.endsWith(".yaml")
|
({ packageManager } = packageJsonFile.endsWith(".yaml")
|
||||||
? parseYaml(content, { merge: true })
|
? parseYaml(content, { merge: true })
|
||||||
: JSON.parse(content)
|
: JSON.parse(content)
|
||||||
packageManager = manifest.packageManager
|
)
|
||||||
devEngines = manifest.devEngines
|
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// Swallow error if package.json doesn't exist in root
|
// Swallow error if package.json doesn't exist in root
|
||||||
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If packageManager field is not set, try devEngines.packageManager
|
|
||||||
if (typeof packageManager !== 'string' && devEngines?.packageManager?.name === 'pnpm' && devEngines.packageManager.version) {
|
|
||||||
packageManager = `pnpm@${devEngines.packageManager.version}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
if (
|
if (
|
||||||
typeof packageManager === 'string' &&
|
typeof packageManager === 'string' &&
|
||||||
@@ -105,8 +98,7 @@ Otherwise, please specify the pnpm version in the action configuration.`)
|
|||||||
throw new Error(`No pnpm version is specified.
|
throw new Error(`No pnpm version is specified.
|
||||||
Please specify it by one of the following ways:
|
Please specify it by one of the following ways:
|
||||||
- in the GitHub Action config with the key "version"
|
- in the GitHub Action config with the key "version"
|
||||||
- in the package.json with the key "packageManager"
|
- in the package.json with the key "packageManager"`)
|
||||||
- in the package.json with the key "devEngines.packageManager"`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!packageManager.startsWith('pnpm@')) {
|
if (!packageManager.startsWith('pnpm@')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user