Skip to content

Commit

Permalink
fix: we only use pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjoeoui committed Dec 1, 2023
1 parent 9574812 commit 5f0497b
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { execSync } = require("child_process");
const { existsSync, readFileSync } = require("fs");
const { existsSync } = require("fs");
const { join } = require("path");

/**
Expand Down Expand Up @@ -72,7 +72,6 @@ const runAction = () => {
const skipBuild = getInput("skip_build") === "true";
const skipInstall = getInput("skip_install") === "true";

const useVueCli = getInput("use_vue_cli") === "true";
const args = getInput("args") || "";
const maxAttempts = Number(getInput("max_attempts") || "1");

Expand All @@ -81,11 +80,6 @@ const runAction = () => {
const appRoot = getInput("app_root") || pkgRoot;

const pkgJsonPath = join(pkgRoot, "package.json");
const pkgLockPath = join(pkgRoot, "package-lock.json");

// Determine whether NPM should be used to run commands (instead of Yarn, which is the default)
const useNpm = existsSync(pkgLockPath);
log(`Will run ${useNpm ? "NPM" : "Yarn"} commands in directory "${pkgRoot}"`);

// Make sure `package.json` file exists
if (!existsSync(pkgJsonPath)) {
Expand All @@ -110,37 +104,24 @@ const runAction = () => {
if (skipInstall) {
log("Skipping install script because `skip_install` option is set");
} else {
log(`Installing dependencies using ${useNpm ? "NPM" : "Yarn"}…`);
run(useNpm ? "npm install" : "yarn", pkgRoot);
log("Installing dependencies using pnpm");
run("pnpm install");
}

// Run NPM build script if it exists
if (skipBuild) {
log("Skipping build script because `skip_build` option is set");
} else {
log("Running the build script…");
if (useNpm) {
run(`npm run ${buildScriptName} --if-present`, pkgRoot);
} else {
// TODO: Use `yarn run ${buildScriptName} --if-present` once supported
// https://github.com/yarnpkg/yarn/issues/6894
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
if (pkgJson.scripts && pkgJson.scripts[buildScriptName]) {
run(`yarn run ${buildScriptName}`, pkgRoot);
}
}
run(`pnpm run ${buildScriptName} --if-present`, pkgRoot);
}

log(`Building${release ? " and releasing" : ""} the Electron app…`);
const cmd = useVueCli
? "vue-cli-service electron:build"
: `electron-package:${platform}`;
const cmd = `electron-package:${platform}`;
for (let i = 0; i < maxAttempts; i += 1) {
try {
run(
`${useNpm ? "npx --no-install" : "pnpm run"} ${cmd} ${
release ? "--publish always" : ""
} ${args}`,
`pnpm run ${cmd} ${release ? "--publish always" : ""} ${args}`,
appRoot,
);
break;
Expand Down

0 comments on commit 5f0497b

Please sign in to comment.