1let isElectron = require("is-electron");
2
3if(isElectron()){
4 console.log("Electron aww yeahhh !");
5}else{
6 console.log("Running in other platform as a normal browser");
7}
1function isElectron() {
2 // Renderer process
3 if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
4 return true;
5 }
6
7 // Main process
8 if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
9 return true;
10 }
11
12 // Detect the user agent when the `nodeIntegration` option is set to true
13 if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
14 return true;
15 }
16
17 return false;
18}
19
20if(isElectron()){
21 console.log("Electron aww yeahhh !");
22}else{
23 console.log("Running in other platform as a normal browser");
24}