Skip to content

Commit

Permalink
feat(SASS/LESS): Add warnings when required dependencies are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Jan 21, 2017
1 parent 5666a06 commit 2d2ff5f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions blueprints/ember-bootstrap/index.js
Expand Up @@ -2,6 +2,7 @@ const rsvp = require('rsvp');
const fs = require('fs');
const path = require('path');
const writeFile = rsvp.denodeify(fs.writeFile);
const chalk = require('chalk');

const bs3Version = '^3.3.7';

Expand Down Expand Up @@ -48,10 +49,10 @@ module.exports = {
fs.mkdirSync(stylePath);
}
if (fs.existsSync(file)) {
this.ui.writeLine(`Added import statement to ${file}`);
this.ui.writeLine(chalk.green(`Added import statement to ${file}`));
return this.insertIntoFile(file, importStatement, {});
} else {
this.ui.writeLine(`Created ${file}`);
this.ui.writeLine(chalk.green(`Created ${file}`));
return writeFile(file, importStatement);
}
}
Expand Down
23 changes: 22 additions & 1 deletion index.js
Expand Up @@ -9,6 +9,7 @@ const Funnel = require('broccoli-funnel');
const stew = require('broccoli-stew');
// const mv = stew.mv;
// const rm = stew.rm;
const chalk = require('chalk');

const defaultOptions = {
importBootstrapTheme: false,
Expand Down Expand Up @@ -56,7 +57,27 @@ module.exports = {
},

findPreprocessor() {
return supportedPreprocessors.find((name) => !!this.app.project.findAddonByName(`ember-cli-${name}`));
return supportedPreprocessors.find((name) => !!this.app.project.findAddonByName(`ember-cli-${name}`) && this.validatePreprocessor(name));
},

validatePreprocessor(name) {
let npmDependencies = this.app.project.dependencies();
let bowerDependencies = this.app.project.bowerDependencies();
switch (name) {
case 'sass':
if (!('bootstrap-sass' in npmDependencies)) {
this.ui.writeLine(chalk.red('Npm package "bootstrap-sass" is missing, but required for SASS support. Please run `ember generate ember-bootstrap` to install the missing dependencies!'));
return false;
}
break;
case 'less':
if (!('bootstrap' in bowerDependencies)) {
this.ui.writeLine(chalk.red('Bower package "bootstrap" is missing, but required for Less support. Please run `ember generate ember-bootstrap` to install the missing dependencies!'));
return false;
}
break;
}
return true;
},

getBootstrapStylesPath() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -73,6 +73,7 @@
"broccoli-funnel": "^1.0.1",
"broccoli-merge-trees": "^1.1.1",
"broccoli-stew": "^1.4.0",
"chalk": "^1.1.3",
"ember-cli-babel": "^5.1.7",
"ember-cli-htmlbars": "^1.0.10",
"ember-runtime-enumerable-includes-polyfill": "^1.0.1",
Expand Down

0 comments on commit 2d2ff5f

Please sign in to comment.