From 01e31ab71cb8f37474edac40f4636638738aee19 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Fri, 3 Jun 2016 09:57:46 -0400 Subject: [PATCH] feat(style): automatically add dependencies if style is set on new projects Fixes #986 --- addon/ng2/blueprints/ng2/files/package.json | 2 +- addon/ng2/blueprints/ng2/index.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index f477c2e6d1f1..bfa667c9c312 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -47,6 +47,6 @@ "ts-node": "^0.5.5", "tslint": "^3.6.0", "typescript": "^1.8.10", - "typings": "^0.8.1" + "typings": "^0.8.1"<%= stylePackage %> } } diff --git a/addon/ng2/blueprints/ng2/index.js b/addon/ng2/blueprints/ng2/index.js index 146ef7c50023..827a95b443e0 100644 --- a/addon/ng2/blueprints/ng2/index.js +++ b/addon/ng2/blueprints/ng2/index.js @@ -2,6 +2,7 @@ const Blueprint = require('ember-cli/lib/models/blueprint'); const path = require('path'); const stringUtils = require('ember-cli-string-utils'); const getFiles = Blueprint.prototype.files; +const EOL = require('os').EOL; module.exports = { description: '', @@ -28,6 +29,17 @@ module.exports = { const fullAppName = stringUtils.dasherize(options.entity.name) .replace(/-(.)/g, (_, l) => ' ' + l.toUpperCase()) .replace(/^./, (l) => l.toUpperCase()); + + var stylePackage = ''; + switch(options.style.toLowerCase()) { + case 'sass': + case 'scss': + stylePackage = `,${EOL} "node-sass": "3.7.0"`; + break; + case 'styl': + stylePackage = `,${EOL} "stylus": "0.54.5"`; + break; + } return { htmlComponentName: stringUtils.dasherize(options.entity.name), @@ -38,7 +50,8 @@ module.exports = { prefix: options.prefix, styleExt: this.styleExt, refToTypings: refToTypings, - isMobile: options.mobile + isMobile: options.mobile, + stylePackage: stylePackage }; },