Lint lib/

The carriers file contains duplicate keys. They have been resolved:
- exact duplicate of ideacellular deleted
- exact duplicate of onlinebeep deleted
- one duplicate of surewestcommunications (%s@freesurf.ch) renamed to
  sunrisecommunications as www.freesurf.ch redirects to sunrise.ch

Unused variables were defined in the library. They have been resolved:
- reference to the `underscore` module deleted
- reference to the `exec` function of the `child_process` module deleted

The carrier argument in text.send was not documented in the library
code. That line of documentation has been added.

The carrier argument in text.send was not being checked as strictly
equal to null. The triple-equals operator has now been applied to
the comparison.

The requires had bad line breakings before commas. The commas have
all been moved to ends of lines instead.

On an unrelated not to lint, the console.log call in the text library
has been switched out with an output call to obey the debug setting.
This commit is contained in:
Valters Jansons 2016-09-20 17:39:09 +03:00
parent ed06e2675c
commit f842ebd65b
2 changed files with 10 additions and 17 deletions

View File

@ -221,15 +221,12 @@ module.exports = {
escotel: [ escotel: [
'%s@escotelmobile.com', '%s@escotelmobile.com',
], ],
surewestcommunications: [ sunrisecommunications: [
'%s@freesurf.ch', '%s@freesurf.ch',
], ],
teliadenmark: [ teliadenmark: [
'%s@gsm1800.telia.dk', '%s@gsm1800.telia.dk',
], ],
ideacellular: [
'%s@ideacellular.net',
],
itelcel: [ itelcel: [
'%s@itelcel.com', '%s@itelcel.com',
], ],
@ -283,9 +280,6 @@ module.exports = {
oneconnectaustria: [ oneconnectaustria: [
'%s@onemail.at', '%s@onemail.at',
], ],
onlinebeep: [
'%s@onlinebeep.net',
],
optusmobile: [ optusmobile: [
'%s@optusmobile.com.au', '%s@optusmobile.com.au',
], ],

View File

@ -1,9 +1,7 @@
var providers = require('./providers.js') var providers = require('./providers.js'),
, _ = require('underscore') carriers = require('./carriers.js'),
, carriers = require('./carriers.js') spawn = require('child_process').spawn,
, exec = require('child_process').exec StringDecoder = require('string_decoder').StringDecoder;
, spawn = require('child_process').spawn;
var StringDecoder = require('string_decoder').StringDecoder;
var debugEnabled = false; var debugEnabled = false;
@ -44,6 +42,7 @@ function debug(enable) {
Params: Params:
phone - phone number to text phone - phone number to text
message - message to send message - message to send
carrier - carrier to use (may be null)
region - region to use (defaults to US) region - region to use (defaults to US)
cb - function(err), provides err messages cb - function(err), provides err messages
*/ */
@ -53,10 +52,10 @@ function sendText(phone, message, carrier, region, cb) {
region = region || 'us'; region = region || 'us';
var providers_list; var providers_list;
if (carrier == null) { if (carrier !== null) {
providers_list = providers[region];
} else {
providers_list = carriers[carrier]; providers_list = carriers[carrier];
} else {
providers_list = providers[region];
} }
var emails = providers_list.map(function(provider) { var emails = providers_list.map(function(provider) {
@ -79,7 +78,7 @@ function sendText(phone, message, carrier, region, cb) {
child.on('exit', function(code, signal) { child.on('exit', function(code, signal) {
cb(false); cb(false);
}); });
console.log(message); output(message);
child.stdin.write(message); child.stdin.write(message);
child.stdin.end(); child.stdin.end();
} }