Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _runMigrations(migrations: Array>): Promise {
if (migrations.length === 0 || !isBackgroundPage()) {
return;
}
const {installType} = await new Promise(resolve => chrome.management.getSelf(resolve));
// Chrome doesn't run `onInstalled` when launching the browser with a pre-loaded development extension #25
if (installType !== 'development') {
await new Promise(resolve => chrome.runtime.onInstalled.addListener(resolve));
}
const options = await this._getAll();
const initial = JSON.stringify(options);
this._log('log', 'Found these stored options', {...options});
this._log('info', 'Will run', migrations.length, migrations.length === 1 ? 'migration' : ' migrations');
migrations.forEach(migrate => migrate(options, this.defaults));