1
0
mirror of https://github.com/pnpm/action-setup.git synced 2026-03-04 08:01:02 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Karl Horky
7ce3debe10
Match versions 2024-04-19 16:45:24 +02:00
Karl Horky
b036c0dcb9
Swallow error on ENOENT 2024-04-19 16:43:36 +02:00
Khải
327b709af8
fix: fmt 2024-04-19 17:57:05 +07:00
Khải
4504319403
fix: fmt 2024-04-19 17:55:58 +07:00

View File

@ -43,14 +43,22 @@ async function readTarget(opts: {
const { version, packageJsonFile, standalone } = opts
const { GITHUB_WORKSPACE } = process.env
let packageManager;
let packageManager
if (GITHUB_WORKSPACE) {
({ packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8')))
try {
({ packageManager } = JSON.parse(await readFile(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8')))
} catch (error) {
// Swallow error if package.json doesn't exist in root
if (error.code !== 'ENOENT') throw error
}
}
if (version) {
if (typeof packageManager === 'string') {
if (
typeof packageManager === 'string' &&
packageManager.replace('pnpm@', '') !== version
) {
throw new Error(`Multiple versions of pnpm specified:
- version ${version} in the GitHub Action config with the key "version"
- version ${packageManager} in the package.json with the key "packageManager"
@ -78,7 +86,7 @@ Please specify it by one of the following ways:
throw new Error('Invalid packageManager field in package.json')
}
if (standalone){
if (standalone) {
return packageManager.replace('pnpm@', '@pnpm/exe@')
}