Extract deprecation warning into separate function
This commit is contained in:
parent
980f63667a
commit
64a0d76af1
26
lib/robot.js
26
lib/robot.js
|
@ -147,8 +147,6 @@ Robot.prototype.initRobot = function(opts) {
|
||||||
//
|
//
|
||||||
// Returns initialized connections
|
// Returns initialized connections
|
||||||
Robot.prototype.initConnections = function(opts) {
|
Robot.prototype.initConnections = function(opts) {
|
||||||
var str;
|
|
||||||
|
|
||||||
this.log("info", "Initializing connections.");
|
this.log("info", "Initializing connections.");
|
||||||
|
|
||||||
if (opts.connection == null && opts.connections == null) {
|
if (opts.connection == null && opts.connections == null) {
|
||||||
|
@ -156,11 +154,7 @@ Robot.prototype.initConnections = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.connection) {
|
if (opts.connection) {
|
||||||
str = "Specifying a single connection with the 'connection' key ";
|
this.deprecationWarning("connection");
|
||||||
str += "is deprecated. It will be removed in 1.0.0.";
|
|
||||||
|
|
||||||
this.log("warn", str);
|
|
||||||
|
|
||||||
this.connection(opts.connection.name, opts.connection);
|
this.connection(opts.connection.name, opts.connection);
|
||||||
return this.connections;
|
return this.connections;
|
||||||
}
|
}
|
||||||
|
@ -231,8 +225,6 @@ Robot.prototype.device = function(name, device) {
|
||||||
//
|
//
|
||||||
// Returns initialized devices
|
// Returns initialized devices
|
||||||
Robot.prototype.initDevices = function(opts) {
|
Robot.prototype.initDevices = function(opts) {
|
||||||
var str;
|
|
||||||
|
|
||||||
this.log("info", "Initializing devices.");
|
this.log("info", "Initializing devices.");
|
||||||
|
|
||||||
if (opts.device == null && opts.devices == null) {
|
if (opts.device == null && opts.devices == null) {
|
||||||
|
@ -245,10 +237,7 @@ Robot.prototype.initDevices = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.device) {
|
if (opts.device) {
|
||||||
str = "Specifying a single device with the 'device' key is deprecated. ";
|
this.deprecationWarning("device");
|
||||||
str += "It will be removed in 1.0.0.";
|
|
||||||
|
|
||||||
this.log("warn", str);
|
|
||||||
this.device(opts.device.name, opts.device);
|
this.device(opts.device.name, opts.device);
|
||||||
return this.devices;
|
return this.devices;
|
||||||
}
|
}
|
||||||
|
@ -439,3 +428,14 @@ Robot.prototype.performArraySetup = function(things, typeOfThing, arrayName) {
|
||||||
this[typeOfThing](name, t);
|
this[typeOfThing](name, t);
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Robot.prototype.deprecationWarning = function(kind) {
|
||||||
|
var msg = "Specifying a single ";
|
||||||
|
msg += kind;
|
||||||
|
msg += " with the '";
|
||||||
|
msg += kind;
|
||||||
|
msg += "' key ";
|
||||||
|
msg += "is deprecated. It will be removed in 1.0.0.";
|
||||||
|
|
||||||
|
this.log("warn", msg);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue