From 032e20f3904f04003becfcd42b437f5c4807a1fd Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 28 Jul 2016 16:46:28 -0500 Subject: [PATCH] Code cleanup --- index.js | 4 ++-- libs/TaskManager.js | 8 +++----- libs/odmOptions.js | 4 ++-- libs/odmRunner.js | 16 ++++------------ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 99006b6..5003f04 100644 --- a/index.js +++ b/index.js @@ -159,7 +159,7 @@ app.get('/getOptions', (req, res) => { let gracefulShutdown = done => { async.series([ - cb => { taskManager.dumpTaskList(cb); }, + cb => taskManager.dumpTaskList(cb), cb => { console.log("Closing server"); server.close(); @@ -180,7 +180,7 @@ let taskManager; let server; async.series([ - cb => { taskManager = new TaskManager(cb); }, + cb => taskManager = new TaskManager(cb), cb => { server = app.listen(3000, err => { if (!err) console.log('Server has started on port 3000'); cb(err); diff --git a/libs/TaskManager.js b/libs/TaskManager.js index 7552852..b2e3e42 100644 --- a/libs/TaskManager.js +++ b/libs/TaskManager.js @@ -33,8 +33,8 @@ module.exports = class TaskManager{ this.runningQueue = []; async.series([ - cb => { this.restoreTaskListFromDump(cb); }, - cb => { this.removeOldTasks(cb); }, + cb => this.restoreTaskListFromDump(cb), + cb => this.removeOldTasks(cb), cb => { this.processNextTask(); cb(); @@ -136,9 +136,7 @@ module.exports = class TaskManager{ removeFromRunningQueue(task){ assert(task.constructor.name === "Task", "Must be a Task object"); - this.runningQueue = this.runningQueue.filter(t => { - return t !== task; - }); + this.runningQueue = this.runningQueue.filter(t => t !== task); } addNew(task){ diff --git a/libs/odmOptions.js b/libs/odmOptions.js index 287ae24..b8d346b 100644 --- a/libs/odmOptions.js +++ b/libs/odmOptions.js @@ -170,7 +170,7 @@ module.exports = { function checkDomain(domain, value){ let dc, matches; - if (dc = domainChecks.find(dc => { return matches = domain.match(dc.regex); })){ + if (dc = domainChecks.find(dc => matches = domain.match(dc.regex))){ if (!dc.validate(matches, value)) throw new Error(`Invalid value ${value} (out of range)`); }else{ throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`); @@ -181,7 +181,7 @@ module.exports = { for (let odmOption of odmOptions){ // Was this option selected by the user? let opt; - if (opt = options.find(o => { return o.name === odmOption.name; })){ + if (opt = options.find(o => o.name === odmOption.name)){ try{ // Convert to proper data type let value = typeConversion[odmOption.type](opt.value); diff --git a/libs/odmRunner.js b/libs/odmRunner.js index 281433c..7299c7f 100644 --- a/libs/odmRunner.js +++ b/libs/odmRunner.js @@ -31,17 +31,11 @@ module.exports = { ], {cwd: ODM_PATH}); childProcess - .on('exit', (code, signal) => { - done(null, code, signal); - }) + .on('exit', (code, signal) => done(null, code, signal)) .on('error', done); - childProcess.stdout.on('data', chunk => { - outputReceived(chunk.toString()); - }); - childProcess.stderr.on('data', chunk => { - outputReceived(chunk.toString()); - }); + childProcess.stdout.on('data', chunk => outputReceived(chunk.toString())); + childProcess.stderr.on('data', chunk => outputReceived(chunk.toString())); return childProcess; }, @@ -63,9 +57,7 @@ module.exports = { }) .on('error', done); - let processOutput = chunk => { - output.push(chunk.toString()); - }; + let processOutput = chunk => output.push(chunk.toString()); childProcess.stdout.on('data', processOutput); childProcess.stderr.on('data', processOutput);