From 26a385d3ac9267d972a7a986ab9749d069ac1656 Mon Sep 17 00:00:00 2001 From: Lasse Sviland Date: Sat, 11 Jun 2016 00:00:27 +0200 Subject: [PATCH 1/3] added flags for specifying path to the app foler, the elements folder and bower_components --- el/index.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/el/index.js b/el/index.js index 49c0fb4..674d709 100644 --- a/el/index.js +++ b/el/index.js @@ -82,16 +82,66 @@ module.exports = yeoman.Base.extend({ var el; var pathToEl; + var pathToElements; + var pathToBowerComponents; + var pathToApp; + + // Let yoy spesify a path to the app folder + if (this.flags.app) { + + // pathToApp = 'subfolder/app' + pathToApp = this.flags.app; + + // adding / to the end of the path + if (pathToApp.charAt(pathToApp.length - 1) !== "/" ) { + pathToApp = pathToApp + "/"; + } + + } else { + + // pathToApp = 'app' + pathToApp = 'app/'; + + } + + + // Let yoy spesify a path to the elements folder relative to the app folder + if (this.flags.elements) { + + // pathToElements = 'app/custom-elements' + pathToElements = pathToApp + this.flags.elements; + + } else { + + // pathToElements = 'app/elements' + pathToElements = pathToApp + 'elements'; + + } + + + // Let yoy spesify a path to the bower_components folder relative to the app folder + if (this.flags.bower) { + + // pathToBowerComponents = 'app/bower_components_folder' + pathToBowerComponents = pathToApp + this.flags.bower; + + } else { + + // pathToBowerComponents = 'app/bower_components' + pathToBowerComponents = pathToApp + 'bower_components'; + + } + if (this.flags.path) { // pathToEl = "app/elements/foo/bar/" - pathToEl = path.join(this.destinationPath('app/elements'), this.flags.path); + pathToEl = path.join(this.destinationPath(pathToElements), this.flags.path); } else { // pathToEl = "app/elements/x-foo/" - pathToEl = path.join(this.destinationPath('app/elements'), this.elementName); + pathToEl = path.join(this.destinationPath(pathToElements), this.elementName); } @@ -101,7 +151,7 @@ module.exports = yeoman.Base.extend({ components: this.components, pathToBower: path.relative( pathToEl, - path.join(process.cwd(), 'app/bower_components') + path.join(process.cwd(), pathToBowerComponents) ) }; @@ -113,15 +163,15 @@ module.exports = yeoman.Base.extend({ // Wire up the dependency in elements.html if (this.includeImport) { - var file = readFileAsString(this.destinationPath('app/elements/elements.html')); + var file = readFileAsString(this.destinationPath(pathToElements + '/elements.html')); el = (this.flags.path || this.elementName) + '/' + this.elementName; el = el.replace(/\\/g, '/'); file += '\n'; - writeFileFromString(file, this.destinationPath('app/elements/elements.html')); + writeFileFromString(file, this.destinationPath(pathToElements + '/elements.html')); } if (this.testType && this.testType !== 'None') { - var testDir = this.destinationPath('app/test'); + var testDir = this.destinationPath(pathToApp + 'test'); if (this.testType === 'TDD') { this.fs.copyTpl( @@ -138,7 +188,7 @@ module.exports = yeoman.Base.extend({ } // Open index.html, locate where to insert text, insert ", x-foo.html" into the array of components to test - var indexFileName = 'app/test/index.html'; + var indexFileName = pathToApp + 'test/index.html'; // Replace single quotes to make JSON happy var origionalFile = readFileAsString(indexFileName).replace(/'/g, '"'); var regex = /WCT\.loadSuites\(([^\)]*)/; From 31e6c63e9252ad17747955d04b295da32dea6cdc Mon Sep 17 00:00:00 2001 From: Lasse Sviland Date: Sat, 11 Jun 2016 13:04:37 +0200 Subject: [PATCH 2/3] fixed typo in comments --- el/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/el/index.js b/el/index.js index 674d709..d4cbcfc 100644 --- a/el/index.js +++ b/el/index.js @@ -86,7 +86,7 @@ module.exports = yeoman.Base.extend({ var pathToBowerComponents; var pathToApp; - // Let yoy spesify a path to the app folder + // Let you specify a path to the app folder if (this.flags.app) { // pathToApp = 'subfolder/app' @@ -105,7 +105,7 @@ module.exports = yeoman.Base.extend({ } - // Let yoy spesify a path to the elements folder relative to the app folder + // Let you specify a path to the elements folder relative to the app folder if (this.flags.elements) { // pathToElements = 'app/custom-elements' @@ -119,7 +119,7 @@ module.exports = yeoman.Base.extend({ } - // Let yoy spesify a path to the bower_components folder relative to the app folder + // Let you specify a path to the bower_components folder relative to the app folder if (this.flags.bower) { // pathToBowerComponents = 'app/bower_components_folder' From 534a3a544d93133d10507b275a9c37e41551f169 Mon Sep 17 00:00:00 2001 From: Lasse Sviland Date: Sat, 11 Jun 2016 13:12:43 +0200 Subject: [PATCH 3/3] changed to singele quotes --- el/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/el/index.js b/el/index.js index d4cbcfc..9de44c4 100644 --- a/el/index.js +++ b/el/index.js @@ -93,8 +93,8 @@ module.exports = yeoman.Base.extend({ pathToApp = this.flags.app; // adding / to the end of the path - if (pathToApp.charAt(pathToApp.length - 1) !== "/" ) { - pathToApp = pathToApp + "/"; + if (pathToApp.charAt(pathToApp.length - 1) !== '/' ) { + pathToApp = pathToApp + '/'; } } else {