-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.js
40 lines (39 loc) · 1.44 KB
/
index.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
var exec = require('child_process').exec,
os = require('os'),
path = require('path'),
rvmDownloader = require('./lib/rvm-downloader'),
fs = require('fs'),
_ = require('lodash'),
defaultOptions = {
rvmPath: path.resolve('OpenFinRVM.exe'),
rvmUrl: 'https://developer.openfin.co/release/rvm/latest'
},
callback;
function launchOpenFin(options, cb) {
callback = callback || cb;
//check if we are in windows.
_.extend(defaultOptions, options);
if (os.type().toLowerCase().indexOf('windows') > -1) {
fs.exists(defaultOptions.rvmPath, function (exists) {
if (exists) {
callback();
exec(defaultOptions.rvmPath + ' --config="' + defaultOptions.configPath +'"', function callback(error) {
console.log('running OpenFin');
if (error) {
console.error(error);
}
});
} else {
console.log('no rvm found at specified location, downloading');
//make sure the second time around we specify the local repository.
defaultOptions.rvmPath = path.resolve('OpenFinRVM.exe');
rvmDownloader.download(defaultOptions.rvmUrl, launchOpenFin);
}
});
} else {
console.error('non windows, launcher not supported.');
}
}
module.exports = {
launchOpenFin: launchOpenFin
};