-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (40 loc) · 1.32 KB
/
index.js
File metadata and controls
49 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
const platform = require('electron-platform');
const pkgJson = require('./package.json');
let profile;
let name = `__electron_profile__`;
let msg = `Failed to require ${pkgJson.name}@${pkgJson.version}:
A different version of ${pkgJson.name} already running in the process, we will redirect to it.
Please make sure your dependencies use the same version of ${pkgJson.name}.`;
if ( platform.isMainProcess ) {
if (global[name]) {
console.warn(msg);
profile = global[name];
} else {
const {app} = require('electron');
const path = require('path');
const fsJetpack = require('fs-jetpack');
profile = global[name] = require('./lib/main');
//
let home = path.join(app.getPath('home'), `.${app.getName()}`);
let local = path.join(home, 'local');
// ensure directories exists
// MacOSX: ~/Library/Logs/.${app-name}
// Windows: %APPDATA%, some where like 'C:\Users\${user_name}\AppData\Local\...'
fsJetpack.dir(home);
fsJetpack.dir(local);
profile.register('global', home);
profile.register('local', local);
}
} else {
if (window[name]) {
console.warn(msg);
profile = window[name];
} else {
profile = window[name] = require('./lib/renderer/index');
}
}
// ==========================
// exports
// ==========================
module.exports = profile;