Skip to content

Commit 25843fd

Browse files
fix(lib): add callback array to nwbuild function
1 parent 1243f6e commit 25843fd

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ nwbuild({
6262

6363
> Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
6464
65+
### Methods
66+
67+
#### nwbuild(options, callbacks)
68+
69+
The function that setups up, runs and builds your NW.js applications. The `callbacks` are for the `run` and `build` function that run inside the `nwbuild` function. The callbacks `callback[0]`, `callback[1]`, `callback[2]` correspond to the `.then`, `.catch` and `.finally` functions of the `run` or `build` promise.
70+
6571
### Options
6672

6773
#### options.mode

lib/index.cjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ NwBuilder.prototype.preparePlatformFiles = function (
10841084
return true;
10851085
};
10861086

1087-
const nwbuild = (options) => {
1087+
const nwbuild = (options, callback = [() => {}, () => {}, () => {}]) => {
10881088
const nw = new NwBuilder(options);
10891089

10901090
nw.on("log", (msg) => {
@@ -1093,14 +1093,14 @@ const nwbuild = (options) => {
10931093

10941094
if (nw.options.mode === "run") {
10951095
nw.run()
1096-
.then(() => {})
1097-
.catch(() => {})
1098-
.finally(() => {});
1096+
.then(callback[0])
1097+
.catch(callback[1])
1098+
.finally(callback[2]);
10991099
} else if (nw.options.mode === "build") {
11001100
nw.build()
1101-
.then(() => {})
1102-
.catch(() => {})
1103-
.finally(() => {});
1101+
.then(callback[0])
1102+
.catch(callback[1])
1103+
.finally(callback[2]);
11041104
} else {
11051105
console.log("[ WARN ] Invalid mode option.");
11061106
}

0 commit comments

Comments
 (0)