Skip to content

Commit

Permalink
fix: use ES6 standard imports for electron modules. Closes #116
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Apr 7, 2020
1 parent 8247952 commit dc0f6e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/index.js
@@ -1,13 +1,11 @@
import electron, { remote } from 'electron';
import { BrowserWindow } from 'electron';
import fs from 'fs';
import path from 'path';
import semver from 'semver';

import downloadChromeExtension from './downloadChromeExtension';
import { getPath } from './utils';

const { BrowserWindow } = remote || electron;

let IDMap = {};
const getIDMapPath = () => path.resolve(getPath(), 'IDMap.json');
if (fs.existsSync(getIDMapPath())) {
Expand All @@ -19,6 +17,12 @@ if (fs.existsSync(getIDMapPath())) {
}

const install = (extensionReference, forceDownload = false) => {
if (process.type !== 'browser') {
return Promise.reject(
new Error('electron-devtools-installer can only be used from the main process'),
);
}

if (Array.isArray(extensionReference)) {
return extensionReference.reduce(
(accum, extension) => accum.then(() => install(extension, forceDownload)),
Expand Down
9 changes: 2 additions & 7 deletions src/utils.js
@@ -1,22 +1,17 @@
import { net } from 'electron';
import { app, net } from 'electron';
import fs from 'fs';
import path from 'path';
import https from 'https';

export const getPath = () => {
const savePath = (remote || electron).app.getPath('userData');
const savePath = app.getPath('userData');
return path.resolve(`${savePath}/extensions`);
};

// Use https.get fallback for Electron < 1.4.5
const request = net ? net.request : https.get;

export const downloadFile = (from, to) => {
if (process.type !== 'browser') {
return Promise.reject(
new Error('electron-devtools-installer can only be used from the main process'),
);
}
return new Promise((resolve, reject) => {
const req = request(from);
req.on('response', (res) => {
Expand Down

0 comments on commit dc0f6e4

Please sign in to comment.