Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.on('ready', () => {
installExtension(REACT_DEVELOPER_TOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err))
installExtension(REDUX_DEVTOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err))
let check = app.getLoginItemSettings().openAtLogin
console.log('start at login:', check)
settings.set('start-login', check)
createWindow()
createPreferencesWindow()
// createWelcomeWindow()
let checkAutomaticallyUpdates = settings.has('check-automatically-updates') ? settings.get('check-automatically-updates') : true
if (checkAutomaticallyUpdates) {
console.log('automatically check updates')
)
if (dev) {
// If dev mode install react and redux extension
// Also open the devtools
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
} = require('electron-devtools-installer')
installExtension(REACT_DEVELOPER_TOOLS)
.then(name => log.info(`Added Extension: ${name}`))
.catch(err => log.info('An error occurred: ', err))
installExtension(REDUX_DEVTOOLS)
.then(name => log.info(`Added Extension: ${name}`))
.catch(err => log.info('An error occurred: ', err))
// newWindow.webContents.openDevTools()
}
windows.add(newWindow)
windowById.set(newWindow.id, newWindow)
// Emitted when the window is closed.
const id = newWindow.id
newWindow.on('closed', function() {
if (process.platform !== 'darwin' && windows.size === 0) {
app.quit()
}
windows.delete(newWindow)
skipTaskbar: true,
})
mainWindow.loadURL(isDev ? 'http://localhost:3000' : url.format({
pathname: path.join(__dirname, '../build', 'index.html'),
protocol: 'file:',
slashes: true
}))
if (isDev) {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS
} = require('electron-devtools-installer')
installExtension(REACT_DEVELOPER_TOOLS)
.then(name => {
console.log(`Added Extension: ${name}`)
})
.catch(err => {
console.log('An error occurred: ', err)
})
}
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
tray = null
})
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true,
}));
if (process.env.NODE_ENV === 'development') {
// Open the DevTools.
mainWindow.webContents.openDevTools();
/* eslint-disable no-console */
installExtension(REACT_DEVELOPER_TOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));
installExtension(REDUX_DEVTOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));
}
// just show the window if all content has been loaded
mainWindow.on('ready-to-show', () => {
mainWindow.show();
mainWindow.focus();
// measure startup time
console.timeEnd('startup'); //eslint-disable-line
});
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
slashes: true,
}) + '?main');
if (dev) {
// Open the DevTools.
mainWindow.webContents.openDevTools();
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
} = require('electron-devtools-installer'); // eslint-disable-line
installExtension(REACT_DEVELOPER_TOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));
installExtension(REDUX_DEVTOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));
}
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
const installExtensions = async () => {
if (process.env.NODE_ENV === 'development') {
const installer = require('electron-devtools-installer'); // eslint-disable-line global-require
const extensions = [
'REACT_DEVELOPER_TOOLS',
'REDUX_DEVTOOLS'
];
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
for (const name of extensions) {
try {
await installer.default(installer[name], forceDownload);
} catch (e) {} // eslint-disable-line
}
}
};
return new Promise((resolve, reject) => {
if (process.env.NODE_ENV === "development") {
const installer = require("electron-devtools-installer"); // eslint-disable-line global-require
const extension = "REACT_DEVELOPER_TOOLS";
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
return installer.default(installer[extension], forceDownload).then(resolve, reject);
}
resolve();
});
extensions.map(name => installer.default(installer[name], forceDownload)),
).catch(console.log);
const installExtensions = async () => {
const {
default: installExtension,
REDUX_DEVTOOLS,
REACT_DEVELOPER_TOOLS,
} = require('electron-devtools-installer');
try {
const result = await Promise.all([
installExtension(REDUX_DEVTOOLS),
installExtension(REACT_DEVELOPER_TOOLS),
]);
console.log('Electron DevTools Installer result:', result);
} catch (e) {
console.log('Electron DevTools Installer error:', e);
}
};
const installExtensions = async () => {
const {
default: installExtension,
REDUX_DEVTOOLS,
REACT_DEVELOPER_TOOLS,
} = require('electron-devtools-installer');
try {
const result = await Promise.all([
installExtension(REDUX_DEVTOOLS),
installExtension(REACT_DEVELOPER_TOOLS),
]);
console.log('Electron DevTools Installer result:', result);
} catch (e) {
console.log('Electron DevTools Installer error:', e);
}
};