MarshallOfSound / electron-devtools-installer

An easy way to ensure Chrome DevTools extensions into Electron

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When passing an array of extensions, only the name of the final extension installed is returned

timsgardner opened this issue · comments

For example,

  const installed = await installExtensions([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS]);
  console.log('installed:', installed);

will print

installed: Redux DevTools

whereas the jsdocs suggest it should return the names of all the extensions:

* @returns A promise resolving with the name or names of the extensions installed

It looks like this is because the reduce in install throws away previous string values:

(accum, extension) => accum.then(() => install(extension, options)),

as a workaround for anyone else encountering this, over on insomnia, we did:

  if (isDevelopment()) {
    try {
      const extensions = [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS];
      const extensionsPlural = extensions.length > 0 ? 's' : '';
      const names = await Promise.all(extensions.map(extension => installExtension(extension)));
      console.log(`[electron-extensions] Added DevTools Extension${extensionsPlural}: ${names.join(', ')}`);
    } catch (err) {
      console.log('[electron-extensions] An error occurred: ', err);
    }
  }