Skip to content

Instantly share code, notes, and snippets.

@rpl
Created August 10, 2016 19:47
Show Gist options
  • Save rpl/48cc87eb161a262f2e30632220e31eb6 to your computer and use it in GitHub Desktop.
Save rpl/48cc87eb161a262f2e30632220e31eb6 to your computer and use it in GitHub Desktop.
use a flow type to pass config data through a Promise chain
type RunConfig = {
runner: ExtensionRunner,
profile: FirefoxProfile,
client?: RemoteFirefox,
addonId?: string,
firefox?: FirefoxProcess,
};
...
.then(({firefox, profile, client, addonId}: RunConfig) => {
if (!client) {
throw new Error('RemoteFirefox `client` should not be missing here');
}
if (!addonId) {
throw new Error('addonId should not be missing here');
}
if (!firefox) {
throw new Error('FirefoxProcess `firefox` should not be missing here');
}
if (noReload) {
log.debug('Extension auto-reloading has been disabled');
} else {
log.debug(
`Reloading extension when the source changes; id=${addonId}`);
reloadStrategy({
firefox, profile, client, sourceDir, artifactsDir, addonId,
});
}
return firefox;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment