Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion bin/action.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
17 changes: 16 additions & 1 deletion src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { exec } from "@actions/exec";
import { existsSync } from "fs";

export type SiteDeploy = {
site: string;
Expand Down Expand Up @@ -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";
}
Comment thread
nstringham marked this conversation as resolved.

async function execWithCredentials(
args: string[],
projectId,
Expand All @@ -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] : []),
Expand Down