Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 57 additions & 7 deletions el/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,66 @@ module.exports = yeoman.Base.extend({

var el;
var pathToEl;
var pathToElements;
var pathToBowerComponents;
var pathToApp;

// Let you specify 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) !== '/' ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested this in Windows? I'm not sure if it'll work as written because they use \ file paths

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous code it do also have the / hardcoded.
pathToEl = path.join(this.destinationPath('app/elements'), this.flags.path);
I have only moved the hardcoded values out to variables that can be changed with the flags.

pathToApp = pathToApp + '/';
}

} else {

// pathToApp = 'app'
pathToApp = 'app/';

}


// Let you specify 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 you specify 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);

}

Expand All @@ -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)
)
};

Expand All @@ -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 += '<link rel="import" href="' + el + '.html">\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(
Expand All @@ -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\(([^\)]*)/;
Expand Down