Skip to content

Commit

Permalink
fix(Install): fixed wrong config being added to ember-cli-build.js
Browse files Browse the repository at this point in the history
…when no preprocessor was used
  • Loading branch information
simonihmig authored Mar 20, 2017
1 parent bf46b39 commit 63210bf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
39 changes: 21 additions & 18 deletions blueprints/ember-bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
},

beforeInstall(option) {
let bootstrapVersion = option.bootstrapVersion = parseInt(option.bootstrapVersion) || 3;
let bootstrapVersion = parseInt(option.bootstrapVersion) || 3;
let preprocessor = option.preprocessor;

if (bootstrapVersion !== 3 && bootstrapVersion !== 4) {
Expand All @@ -48,9 +48,9 @@ module.exports = {
if (!preprocessor) {
let dependencies = this.project.dependencies();
if ('ember-cli-sass' in dependencies) {
preprocessor = option.preprocessor = 'sass';
preprocessor = 'sass';
} else if ('ember-cli-less' in dependencies) {
preprocessor = option.preprocessor = 'less';
preprocessor = 'less';
} else {
preprocessor = 'none';
}
Expand All @@ -61,13 +61,16 @@ module.exports = {
}

this.ui.writeLine(chalk.green(`Installing for Bootstrap ${bootstrapVersion} using preprocessor ${preprocessor}`));

this.bootstrapVersion = bootstrapVersion;
this.preprocessor = preprocessor;
},

afterInstall(option) {
return this.adjustBootstrapDependencies(option)
.then(() => this.adjustPreprocessorDependencies(option))
.then(() => this.addPreprocessorStyleImport(option))
.then(() => this.addBuildConfiguration(option));
afterInstall() {
return this.adjustBootstrapDependencies()
.then(() => this.adjustPreprocessorDependencies())
.then(() => this.addPreprocessorStyleImport())
.then(() => this.addBuildConfiguration());
},

removePackageFromBowerJSON(dependency) {
Expand All @@ -88,9 +91,9 @@ module.exports = {
});
},

adjustBootstrapDependencies(option) {
let bootstrapVersion = option.bootstrapVersion;
let preprocessor = option.preprocessor;
adjustBootstrapDependencies() {
let bootstrapVersion = this.bootstrapVersion;
let preprocessor = this.preprocessor;
let dependencies = this.project.dependencies();
let bowerDependencies = this.project.bowerDependencies();
let promises = [];
Expand Down Expand Up @@ -122,8 +125,8 @@ module.exports = {
return rsvp.all(promises);
},

adjustPreprocessorDependencies(option) {
let preprocessor = option.preprocessor;
adjustPreprocessorDependencies() {
let preprocessor = this.preprocessor;
let dependencies = this.project.dependencies();
let promises = [];

Expand All @@ -146,8 +149,8 @@ module.exports = {
return rsvp.all(promises);
},

addPreprocessorStyleImport(option) {
let preprocessor = option.preprocessor;
addPreprocessorStyleImport() {
let preprocessor = this.preprocessor;
let importStatement = '\n@import "ember-bootstrap/bootstrap";\n';

if (preprocessor === 'none') {
Expand All @@ -171,10 +174,10 @@ module.exports = {
}
},

addBuildConfiguration(option) {
addBuildConfiguration() {
let file = 'ember-cli-build.js';
let bootstrapVersion = option.bootstrapVersion;
let preprocessor = option.preprocessor;
let bootstrapVersion = this.bootstrapVersion;
let preprocessor = this.preprocessor;
let settings = {
bootstrapVersion
};
Expand Down
20 changes: 12 additions & 8 deletions node-tests/blueprints/ember-bootstrap-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ describe('Acceptance: ember generate ember-bootstrap', function() {
let args = ['ember-bootstrap'];

return emberNew()
.then(() => emberGenerate(args, (file) => {
.then(() => emberGenerate(args))
.then(() => {
expect(file('app/styles/app.scss')).to.not.exist;
expect(file('app/styles/app.less')).to.not.exist;
}));
});
});

it('creates app.scss if not existing and ember-cli-sass is present', function() {
Expand All @@ -71,10 +72,11 @@ describe('Acceptance: ember generate ember-bootstrap', function() {
{ name: 'ember-cli-sass' }
]))
.then(() => createStyleFixture('app.scss'))
.then(() => emberGenerate(args, (file) => {
.then(() => emberGenerate(args))
.then(() => {
expect(file('app/styles/app.scss')).to.contain('@import "ember-bootstrap/bootstrap";');
expect(file('app/styles/app.less')).to.not.exist;
}));
});
});

it('creates app.less if not existing and ember-cli-less is present', function() {
Expand Down Expand Up @@ -117,10 +119,11 @@ describe('Acceptance: ember generate ember-bootstrap', function() {
let args = ['ember-bootstrap', '--preprocessor=none'];

return emberNew()
.then(() => emberGenerate(args, (file) => {
.then(() => emberGenerate(args))
.then(() => {
expect(file('app/styles/app.scss')).to.not.exist;
expect(file('app/styles/app.less')).to.not.exist;
}));
});
});

it('creates app.scss if not existing and --preprocessor=sass', function() {
Expand All @@ -140,10 +143,11 @@ describe('Acceptance: ember generate ember-bootstrap', function() {

return emberNew()
.then(() => createStyleFixture('app.scss'))
.then(() => emberGenerate(args, (file) => {
.then(() => emberGenerate(args))
.then(() => {
expect(file('app/styles/app.scss')).to.contain('@import "ember-bootstrap/bootstrap";');
expect(file('app/styles/app.less')).to.not.exist;
}));
});
});

it('creates app.less if not existing and --preprocessor=less', function() {
Expand Down

0 comments on commit 63210bf

Please sign in to comment.