/
execute-command.js
55 lines (39 loc) · 1.19 KB
/
execute-command.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var bb8 = require('./bb8-instance')(),
appRootPath = require('app-root-path'),
_ = require('lodash');
module.exports.connectAndSendCustomCommand = function(filePath, options) {
if (bb8) {
bb8.connect(function () {
require(filePath)(bb8, options);
});
return;
}
console.log("BB8 Is not Connected");
}
module.exports.connectAndSendCommand = function (command, options) {
if (bb8) {
bb8.connect(function () {
require(appRootPath + '/commands/' + command)(bb8, options);
});
return;
}
console.log("BB8 Is not Connected");
};
module.exports.alreadyConnected = function (bb8, command) {
if (bb8) {
return require(appRootPath + '/commands/' + command)(bb8);
}
console.log("BB8 Is not Connected");
};
module.exports.alreadyConnectedSingleValue = function (bb8, command, options) {
if (bb8) {
return require(appRootPath + '/commands/' + command)(bb8, options);
}
console.log("BB8 Is not Connected");
};
module.exports.alreadyConnectedMultipleValues = function (bb8, command, options) {
if (bb8) {
return require(appRootPath + '/commands/' + command).apply(this, _.union([bb8], options));
}
console.log("BB8 Is not Connected");
};