diff --git a/bin/action.min.js b/bin/action.min.js index 7291ada8..729b0137 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -92942,13 +92942,26 @@ function interpretChannelDeployResult(deployResult) { urls }; } +function getPackageManagerExecuteCommand() { + if (fs.existsSync("./package-lock.json")) { + return "npx"; + } + if (fs.existsSync("./yarn.lock") && fs.existsSync("./.yarnrc.yml")) { + return "yarn dlx"; + } + if (fs.existsSync("./pnpm-lock.yaml")) { + return "pnpm dlx"; + } + return "npx"; +} async function execWithCredentials(args, projectId, gacFilename, opts) { let deployOutputBuf = []; const debug = opts.debug || false; const firebaseToolsVersion = opts.firebaseToolsVersion || "latest"; const force = opts.force; + const packageManager = getPackageManagerExecuteCommand(); try { - await exec_1.exec(`npx firebase-tools@${firebaseToolsVersion}`, [...args, ...(projectId ? ["--project", projectId] : []), ...(force ? ["--force"] : []), debug ? "--debug" // gives a more thorough error message + await exec_1.exec(`${packageManager} firebase-tools@${firebaseToolsVersion}`, [...args, ...(projectId ? ["--project", projectId] : []), ...(force ? ["--force"] : []), debug ? "--debug" // gives a more thorough error message : "--json" // allows us to easily parse the output ], { listeners: { diff --git a/src/deploy.ts b/src/deploy.ts index f7a419b7..08fa7552 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -15,6 +15,7 @@ */ import { exec } from "@actions/exec"; +import { existsSync } from "fs"; export type SiteDeploy = { site: string; @@ -74,6 +75,19 @@ export function interpretChannelDeployResult( }; } +function getPackageManagerExecuteCommand(): string { + if (existsSync("./package-lock.json")) { + return "npx"; + } + if (existsSync("./yarn.lock") && existsSync("./.yarnrc.yml")) { + return "yarn dlx"; + } + if (existsSync("./pnpm-lock.yaml")) { + return "pnpm dlx"; + } + return "npx"; +} + async function execWithCredentials( args: string[], projectId, @@ -84,10 +98,11 @@ async function execWithCredentials( const debug = opts.debug || false; const firebaseToolsVersion = opts.firebaseToolsVersion || "latest"; const force = opts.force; + const packageManager = getPackageManagerExecuteCommand(); try { await exec( - `npx firebase-tools@${firebaseToolsVersion}`, + `${packageManager} firebase-tools@${firebaseToolsVersion}`, [ ...args, ...(projectId ? ["--project", projectId] : []),