mirror of
https://github.com/pnpm/action-setup.git
synced 2026-03-04 08:01:02 +08:00
Compare commits
4 Commits
1ecf7e8d5f
...
7ce3debe10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ce3debe10 | ||
|
|
b036c0dcb9 | ||
|
|
327b709af8 | ||
|
|
4504319403 |
@ -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@')
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user