Clean up initialization methods for adaptors/drivers
This commit is contained in:
parent
5650ce1d60
commit
ef3aaf6591
31
lib/robot.js
31
lib/robot.js
|
@ -252,24 +252,23 @@ namespace("Cylon", function() {
|
|||
//
|
||||
// Returns the adaptor
|
||||
Robot.prototype.initAdaptor = function(adaptorName, connection, opts) {
|
||||
var realAdaptor, testAdaptor;
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
realAdaptor = this.robot.requireAdaptor(adaptorName).adaptor({
|
||||
if (opts == null) { opts = {}; }
|
||||
|
||||
var adaptor = this.robot.requireAdaptor(adaptorName).adaptor({
|
||||
name: adaptorName,
|
||||
connection: connection,
|
||||
extraParams: opts
|
||||
});
|
||||
|
||||
if (CylonConfig.testing_mode) {
|
||||
testAdaptor = this.robot.requireAdaptor('test').adaptor({
|
||||
var testAdaptor = this.robot.requireAdaptor('test').adaptor({
|
||||
name: adaptorName,
|
||||
connection: connection,
|
||||
extraParams: opts
|
||||
});
|
||||
return proxyTestStubs(realAdaptor.commands(), testAdaptor);
|
||||
return proxyTestStubs(adaptor.commands(), testAdaptor);
|
||||
} else {
|
||||
return realAdaptor;
|
||||
return adaptor;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -306,24 +305,24 @@ namespace("Cylon", function() {
|
|||
//
|
||||
// Returns the new driver
|
||||
Robot.prototype.initDriver = function(driverName, device, opts) {
|
||||
var realDriver, testDriver;
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
realDriver = this.robot.requireDriver(driverName).driver({
|
||||
if (opts == null) { opts = {}; }
|
||||
|
||||
var driver = this.robot.requireDriver(driverName).driver({
|
||||
name: driverName,
|
||||
device: device,
|
||||
extraParams: opts
|
||||
});
|
||||
|
||||
if (CylonConfig.testing_mode) {
|
||||
testDriver = this.robot.requireDriver('test').driver({
|
||||
var testDriver = this.robot.requireDriver('test').driver({
|
||||
name: driverName,
|
||||
device: device,
|
||||
extraParams: opts
|
||||
});
|
||||
return proxyTestStubs(realDriver.commands(), testDriver);
|
||||
|
||||
return proxyTestStubs(driver.commands(), testDriver);
|
||||
} else {
|
||||
return realDriver;
|
||||
return driver;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue