-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
41 lines (36 loc) · 992 Bytes
/
main.js
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
var fs = require('fs'),
pathUtil = require('path'),
exec = require('child_process').exec;
var packages = [
'./app',
'./browser-window',
'./global-shortcut',
'./electron'
];
// symlinks the packages into the node_modules of an electron app
function addSymlink(path) {
packages.forEach(function(package) {
var target = pathUtil.resolve(path,'./node_modules', package);
if(! fs.existsSync(pathUtil.resolve(path, './node_modules'))) {
fs.mkdirSync(pathUtil.resolve(path, './node_modules'));
}
try {
fs.symlinkSync( pathUtil.resolve(__dirname, package), target, 'dir');
} catch (e) {
if(e.code !== 'EEXIST') {
throw e;
}
}
});
}
// removes the symlinks that were added in addSymlink
function removeSymlink(path) {
packages.forEach(function(package) {
var target = pathUtil.resolve(path,'./node_modules', package);
fs.unlinkSync(target);
});
}
module.exports = {
add: addSymlink,
remove: removeSymlink
};