From 0cb0538c3379cd0ac5d91e57e3a60f7230c5ead3 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Thu, 6 Feb 2025 21:04:41 +0000 Subject: [PATCH] feat: support `package.yaml` (#156) --- src/install-pnpm/run.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/install-pnpm/run.ts b/src/install-pnpm/run.ts index e02fb98..5e04d08 100644 --- a/src/install-pnpm/run.ts +++ b/src/install-pnpm/run.ts @@ -6,6 +6,7 @@ import path from 'path' import { execPath } from 'process' import util from 'util' import { Inputs } from '../inputs' +import YAML from 'yaml' export async function runSelfInstaller(inputs: Inputs): Promise { const { version, dest, packageJsonFile, standalone } = inputs @@ -49,7 +50,11 @@ async function readTarget(opts: { if (GITHUB_WORKSPACE) { try { - ({ packageManager } = JSON.parse(readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'))) + const content = readFileSync(path.join(GITHUB_WORKSPACE, packageJsonFile), 'utf8'); + ({ packageManager } = packageJsonFile.endsWith(".yaml") + ? YAML.parse(content, { merge: true }) + : JSON.parse(content) + ) } catch (error: unknown) { // Swallow error if package.json doesn't exist in root if (!util.types.isNativeError(error) || !('code' in error) || error.code !== 'ENOENT') throw error @@ -66,7 +71,7 @@ async function readTarget(opts: { - version ${packageManager} in the package.json with the key "packageManager" Remove one of these versions to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION`) } - + return `${ standalone ? '@pnpm/exe' : 'pnpm' }@${version}` }