From 1ecb75cd2cfcdf5ab8ff3d7cfc03914e6b40b448 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Wed, 18 Jan 2017 01:48:00 -0800 Subject: [PATCH] Fixed dash-list bug --- src/local/dashlist.js | 19 +++++++++---------- src/remote/s3services.js | 4 ++-- src/util/config.js | 9 ++++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/local/dashlist.js b/src/local/dashlist.js index 854c8c5..f07c763 100644 --- a/src/local/dashlist.js +++ b/src/local/dashlist.js @@ -14,7 +14,6 @@ var dashListFile = 'conf/dash-list.json'; function DashList() { this.dashlistConf = require('nconf'); - this.dashlistConf.add('dashlist.conf', {type: 'file', file: dashListFile}); } @@ -34,7 +33,7 @@ DashList.prototype.createList = function(commands) { var self = this; var listName = commands[0]; self.createIfNotExists(false); - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); if (!self.dashlistConf.get('dashlists')) { self.dashlistConf.set('dashlists', []); self.saveDashListConf(false); @@ -55,7 +54,7 @@ DashList.prototype.addDashboard = function(commands) { var self = this; var listName = commands[0]; var dashboardName = commands[1]; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -72,7 +71,7 @@ DashList.prototype.removeDashboard = function(commands) { var self = this; var listName = commands[0]; var dashboardName = commands[1]; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -89,7 +88,7 @@ DashList.prototype.removeDashboard = function(commands) { DashList.prototype.showList = function(commands) { var self = this; var listName = commands[0]; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -103,7 +102,7 @@ DashList.prototype.showList = function(commands) { DashList.prototype.clearList = function(commands) { var self = this; var listName = commands[0]; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -119,7 +118,7 @@ DashList.prototype.clearList = function(commands) { DashList.prototype.deleteList = function(commands) { var self = this; var listName = commands[0]; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -134,7 +133,7 @@ DashList.prototype.deleteList = function(commands) { DashList.prototype.getList = function(listName) { var self = this; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); var listIndex = getListIndex(listName, lists); if (listIndex === -1) { @@ -154,7 +153,7 @@ function getListIndex(listName, lists) { DashList.prototype.getListNames = function() { var self = this; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); var lists = self.dashlistConf.get('dashlists'); if (lists && lists.length > 0) { return _.map(lists, function (list) { @@ -169,7 +168,7 @@ DashList.prototype.getListNames = function() { // Save dashlist config DashList.prototype.saveDashListConf = function(showOutput) { var self = this; - self.dashlistConf.use('dashlist.conf'); + self.dashlistConf.use('file', {file: dashListFile}); self.dashlistConf.save(function (err) { if (err) { if (showOutput) { diff --git a/src/remote/s3services.js b/src/remote/s3services.js index 99b0d91..2f01dee 100644 --- a/src/remote/s3services.js +++ b/src/remote/s3services.js @@ -10,10 +10,10 @@ var _ = require('lodash'); //Create the s3 bucket and required directories function S3(conf, comps) { this.params = {}; - if (conf.s3 && conf.s3.bucket_name) { + if (conf && conf.s3 && conf.s3.bucket_name) { this.params.Bucket = conf.s3.bucket_name; } - if (conf.s3 && conf.s3.path) { + if (conf && conf.s3 && conf.s3.path) { this.params.Key = conf.s3.path; } this.components = comps; diff --git a/src/util/config.js b/src/util/config.js index 2ac7141..639ea5e 100644 --- a/src/util/config.js +++ b/src/util/config.js @@ -34,7 +34,6 @@ var confFile = 'conf/wizzy.json'; // Constructor function Config() { this.conf = require('nconf'); - this.conf.add('wizzy.conf', {type: 'file', file: confFile}); } // Initialize wizzy configuration @@ -78,7 +77,7 @@ Config.prototype.checkConfigPrereq = function(showOutput) { Config.prototype.addProperty = function(key, value) { var self = this; self.checkConfigPrereq(); - self.conf.use('wizzy.conf'); + self.conf.use('file', {file: confFile}); if (_.includes(configs, key)) { self.conf.set(key, value); self.saveConfig(true); @@ -92,7 +91,7 @@ Config.prototype.addProperty = function(key, value) { Config.prototype.showProperty = function(config) { var self = this; self.checkConfigPrereq(); - self.conf.use('wizzy.conf'); + self.conf.use('file', {file: confFile}); logger.showOutput(logger.stringify(self.conf.get(config))); }; @@ -100,14 +99,14 @@ Config.prototype.showProperty = function(config) { Config.prototype.getProperty = function(config) { var self = this; self.checkConfigPrereq(); - self.conf.use('wizzy.conf'); + self.conf.use('file', {file: confFile}); return(self.conf.get(config)); }; // Save wizzy config file Config.prototype.saveConfig = function(showOutput) { var self = this; - self.conf.use('wizzy.conf'); + self.conf.use('file', {file: confFile}); self.conf.save(function (err) { if (err) { if (showOutput) {