Skip to content
This repository was archived by the owner on Oct 13, 2024. It is now read-only.

Commit e0d47fa

Browse files
leclercbsamuelmeuli
authored andcommitted
Add build_script_name option (#13)
1 parent a6fc1dd commit e0d47fa

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ After building successfully, the action will publish your release artifacts. By
7272
You can configure the action further with the following options:
7373

7474
- `package_root`: Directory where NPM/Yarn commands should be run (default: `"."`)
75+
- `build_script_name`: Name of the optional NPM build script which is executed before `electron-builder` (default: `"build"`)
7576

7677
See [`action.yml`](./action.yml) for a list of all possible input variables.
7778

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ inputs:
2626
description: Directory where NPM/Yarn commands should be run
2727
required: false
2828
default: "."
29+
build_script_name:
30+
description: Name of the optional NPM build script which is executed before `electron-builder`
31+
required: false
32+
default: build
2933

3034
# Deprecated
3135
app_root:

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const runAction = () => {
6767
const platform = getPlatform();
6868
const release = getInput("release", true) === "true";
6969
const pkgRoot = getInput("package_root", true);
70+
const buildScriptName = getInput("build_script_name", true);
7071

7172
// TODO: Deprecated option, remove in v2.0. `electron-builder` always requires a `package.json` in
7273
// the same directory as the Electron app, so the `package_root` option should be used instead
@@ -106,13 +107,13 @@ const runAction = () => {
106107
// Run NPM build script if it exists
107108
log("Running the build script…");
108109
if (useNpm) {
109-
run("npm run build --if-present", pkgRoot);
110+
run(`npm run ${buildScriptName} --if-present`, pkgRoot);
110111
} else {
111-
// TODO: Use `yarn run build --if-present` once supported
112+
// TODO: Use `yarn run ${buildScriptName} --if-present` once supported
112113
// https://github.com/yarnpkg/yarn/issues/6894
113114
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
114-
if (pkgJson.scripts && pkgJson.scripts.build) {
115-
run("yarn build", pkgRoot);
115+
if (pkgJson.scripts && pkgJson.scripts[buildScriptName]) {
116+
run(`yarn run ${buildScriptName}`, pkgRoot);
116117
}
117118
}
118119

0 commit comments

Comments
 (0)