diff --git a/blueprints/ember-bootstrap/index.js b/blueprints/ember-bootstrap/index.js index 11601d5d3..0bf9fc451 100644 --- a/blueprints/ember-bootstrap/index.js +++ b/blueprints/ember-bootstrap/index.js @@ -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'; @@ -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); } } diff --git a/index.js b/index.js index 471ed3656..516c65da7 100644 --- a/index.js +++ b/index.js @@ -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, @@ -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() { diff --git a/package.json b/package.json index d4ff8abb7..ec1ccda87 100644 --- a/package.json +++ b/package.json @@ -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",