Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(project): queue spinner promises on watch #20

Merged
merged 1 commit into from
Jun 8, 2017
Merged
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
7 changes: 6 additions & 1 deletion src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,21 @@ export default class Project {
addonProject.watch({ onBuild: options.onBuild, outputDir: addonDist });
});

let spinnerStart: Promise<void>;

// Handle watcher events
watcher.on('buildstart', async () => {
debug('changes detected, rebuilding');
await spinner.start(`Building ${ this.pkg.name }`);
timer = startTimer();
spinnerStart = spinner.start(`Building ${ this.pkg.name }`);
await spinnerStart;
});
watcher.on('change', async (results: { directory: string, graph: any }) => {
debug('rebuild finished, wrapping up');
this.finishBuild(results, options.outputDir);
await spinnerStart;
await spinner.succeed(`${ this.pkg.name } build complete (${ timer.stop() }s)`);
spinnerStart = null;
options.onBuild(this);
});
watcher.on('error', async (error: any) => {
Expand Down