From 4e21ada3f7e4472da4cc5e5260a392d141cccafb Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Mon, 17 Aug 2015 16:07:03 -0700 Subject: [PATCH] all: remove equal sign symmetry, breaks codeformatter --- lib/jaws.js | 14 ++-- lib/jaws_command_install.js | 152 +++++++++++++++++------------------- lib/jaws_utils.js | 5 +- 3 files changed, 82 insertions(+), 89 deletions(-) diff --git a/lib/jaws.js b/lib/jaws.js index e7e99b371..b25b7fa88 100755 --- a/lib/jaws.js +++ b/lib/jaws.js @@ -6,17 +6,17 @@ * - Require order is important */ -var JAWS = {}; +var JAWS = {}; // Add utils -JAWS._utils = require('./jaws_utils'); +JAWS._utils = require('./jaws_utils'); // Add meta data -JAWS._meta = {}; -JAWS._meta.version = require('./../package.json').version; -JAWS._meta.cwd = process.cwd(); -JAWS._meta.projectRootPath = JAWS._utils.findProjectRootPath(); -JAWS._meta.projectJson = JAWS._meta.projectRootPath ? require(JAWS._meta.projectRootPath + '/jaws.json') : false; +JAWS._meta = {}; +JAWS._meta.version = require('./../package.json').version; +JAWS._meta.cwd = process.cwd(); +JAWS._meta.projectRootPath = JAWS._utils.findProjectRootPath(); +JAWS._meta.projectJson = JAWS._meta.projectRootPath ? require(JAWS._meta.projectRootPath + '/jaws.json') : false; // Fetch AWS Admin credentials, if any if (JAWS._meta.projectRootPath) { diff --git a/lib/jaws_command_install.js b/lib/jaws_command_install.js index ee32feb35..82dafa7cf 100644 --- a/lib/jaws_command_install.js +++ b/lib/jaws_command_install.js @@ -6,26 +6,26 @@ */ // Defaults -var Promise = require('bluebird'), -fs = Promise.promisifyAll(require('fs')), -del = require('del'), -wrench = require('wrench'), -shortid = require('shortid'), -download = require('download'); +var Promise = require('bluebird'), + fs = Promise.promisifyAll(require('fs')), + del = require('del'), + wrench = require('wrench'), + shortid = require('shortid'), + download = require('download'); -module.exports = function(JAWS) { +module.exports = function(JAWS) { - JAWS.install = function(url) { + JAWS.install = function(url) { // Inform console.log('****** JAWS: Downloading and installing module...'); // Prepare URL var repo = {}; - url = url.replace('https://','').replace('http://','').replace('www.','').split('/'); - repo.owner = url[1]; - repo.repo = url[2]; - repo.branch = 'master'; + url = url.replace('https://', '').replace('http://', '').replace('www.', '').split('/'); + repo.owner = url[1]; + repo.repo = url[2]; + repo.branch = 'master'; if (~repo.repo.indexOf('#')) { url[2].split('#'); @@ -37,13 +37,7 @@ module.exports = function(JAWS) { if (url[0] !== 'github.com' || !repo.owner || !repo.repo) return console.log('****** JAWS Error: Must be a github url in this format: https://github.com/jaws-stack/JAWS'); // Prepare download url - var downloadUrl = 'https://github.com/' - + repo.owner - + '/' - + repo.repo - + '/archive/' - + repo.branch - + '.zip'; + var downloadUrl = 'https://github.com/' + repo.owner + '/' + repo.repo + '/archive/' + repo.branch + '.zip'; // Make a temporary directory for the module var tempDir = 'temp-' + shortid.generate(); @@ -51,70 +45,70 @@ module.exports = function(JAWS) { // Download module new download({ - timeout: 30000, - extract: true, - strip: 1, - mode: '755' - }) - .get(downloadUrl) - .dest(tempDirPath) - .run(function(error, files) { + timeout: 30000, + extract: true, + strip: 1, + mode: '755' + }) + .get(downloadUrl) + .dest(tempDirPath) + .run(function(error, files) { - if (error) { - console.log('****** JAWS Error: Module download and installation failed.'); - return console.log(error); - } - - // Fetch module's jaws.json - try { - var jawsJson = require(tempDirPath + '/jaws.json'); - } catch(e) { - - // Remove module and report if malformed - del([tempDirPath], function (error) { - if (error) console.log(error); - return console.log(e); - }); - - } - - // Handle according to module profile - if (['lambda', 'lambdaGroup'].indexOf(jawsJson.profile) > -1) { - - // If folder exists, create unique module folder name - if (fs.existsSync( JAWS._meta.projectRootPath + '/back/' + jawsJson.name)) { - for (var i = 2;i < 500;i++) { - if (!fs.existsSync( JAWS._meta.projectRootPath + '/back/' + jawsJson.name + '-' + i)) { - jawsJson.name = jawsJson.name + '-' + i; - break; - } - } + if (error) { + console.log('****** JAWS Error: Module download and installation failed.'); + return console.log(error); } - // Copy folders into new module folder - wrench.copyDirSyncRecursive(tempDirPath, JAWS._meta.projectRootPath + '/back/' + jawsJson.name, { - forceDelete: false, // Whether to overwrite existing directory or not - excludeHiddenUnix: false // Whether to copy hidden Unix files or not (preceding .) - // filter: regexpOrFunction // A filter to match files against; if matches, do nothing (exclude). + // Fetch module's jaws.json + try { + var jawsJson = require(tempDirPath + '/jaws.json'); + } catch (e) { + + // Remove module and report if malformed + del([tempDirPath], function(error) { + if (error) console.log(error); + return console.log(e); + }); + + } + + // Handle according to module profile + if (['lambda', 'lambdaGroup'].indexOf(jawsJson.profile) > -1) { + + // If folder exists, create unique module folder name + if (fs.existsSync(JAWS._meta.projectRootPath + '/back/' + jawsJson.name)) { + for (var i = 2; i < 500; i++) { + if (!fs.existsSync(JAWS._meta.projectRootPath + '/back/' + jawsJson.name + '-' + i)) { + jawsJson.name = jawsJson.name + '-' + i; + break; + } + } + } + + // Copy folders into new module folder + wrench.copyDirSyncRecursive(tempDirPath, JAWS._meta.projectRootPath + '/back/' + jawsJson.name, { + forceDelete: false, // Whether to overwrite existing directory or not + excludeHiddenUnix: false // Whether to copy hidden Unix files or not (preceding .) + // filter: regexpOrFunction // A filter to match files against; if matches, do nothing (exclude). + }); + + } else if (jawsJson.profile === 'front') { + + } else if (jawsJson.profile === 'project') { + + } else { + return console.log('****** JAWS Error: This module has an unknown profile'); + } + + // Delete temp directory + del([tempDirPath], function(error) { + + if (error) return console.log(error); + + // Conclude + return console.log('****** JAWS: Module successfully installed'); + }); - - } else if (jawsJson.profile === 'front') { - - } else if (jawsJson.profile === 'project') { - - } else { - return console.log('****** JAWS Error: This module has an unknown profile'); - } - - // Delete temp directory - del([tempDirPath], function (error) { - - if (error) return console.log(error); - - // Conclude - return console.log('****** JAWS: Module successfully installed'); - }); - }); }; }; diff --git a/lib/jaws_utils.js b/lib/jaws_utils.js index 059ab7b7a..f5937e666 100644 --- a/lib/jaws_utils.js +++ b/lib/jaws_utils.js @@ -4,9 +4,8 @@ * JAWS CLI: Utilities */ - -var Promise = require('bluebird'), -fs = Promise.promisifyAll(require('fs')); +var Promise = require('bluebird'), + fs = Promise.promisifyAll(require('fs')); module.exports.findProjectRootPath = function() {