Skip to content

Commit 26f23b4

Browse files
MarshallOfSoundmalept
authored andcommitted
feat(rebuilder): show rebuild progress from the electron-rebuild lifecycle
1 parent 3d26da5 commit 26f23b4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/util/rebuild.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
import rebuild from 'electron-rebuild';
22

3-
export default (buildPath, electronVersion, platform, arch) => rebuild(buildPath, electronVersion, arch);
3+
import asyncOra from '../util/ora-handler';
4+
5+
export default async (buildPath, electronVersion, platform, arch) => {
6+
await asyncOra('Preparing native dependencies', async (rebuildSpinner) => {
7+
const rebuilder = rebuild(buildPath, electronVersion, arch);
8+
const { lifecycle } = rebuilder;
9+
10+
let found = 0;
11+
let done = 0;
12+
13+
const redraw = () => {
14+
rebuildSpinner.text = `Preparing native dependencies: ${done} / ${found}`; // eslint-disable-line
15+
};
16+
17+
lifecycle.on('module-found', () => { found += 1; redraw(); });
18+
lifecycle.on('module-done', () => { done += 1; redraw(); });
19+
20+
await rebuilder;
21+
});
22+
};

0 commit comments

Comments
 (0)