Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
feat(gen): add Compass support to the initialization process
Browse files Browse the repository at this point in the history
Twitter Bootstrap with the Compass CSS Authoring Framework question will show up only if both Compass and Bootstrap have both been enabled
  • Loading branch information
samaxes authored and eddiemonge committed Dec 13, 2013
1 parent 4ab6eb2 commit 7fac119
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 19 deletions.
22 changes: 19 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,23 @@ Generator.prototype.welcome = function welcome() {
}
};

Generator.prototype.askForCompass = function askForCompass() {
var cb = this.async();

this.prompt([{
type: 'confirm',
name: 'compass',
message: 'Would you like to use Sass (with Compass)?',
default: true
}], function (props) {
this.compass = props.compass;

cb();
}.bind(this));
};

Generator.prototype.askForBootstrap = function askForBootstrap() {
var compass = this.compass;
var cb = this.async();

this.prompt([{
Expand All @@ -140,10 +156,10 @@ Generator.prototype.askForBootstrap = function askForBootstrap() {
}, {
type: 'confirm',
name: 'compassBootstrap',
message: 'Would you like to use the SCSS version of Twitter Bootstrap with the Compass CSS Authoring Framework?',
message: 'Would you like to use the Sass version of Twitter Bootstrap?',
default: true,
when: function (props) {
return props.bootstrap;
return props.bootstrap && compass;
}
}], function (props) {
this.bootstrap = props.bootstrap;
Expand Down Expand Up @@ -218,7 +234,7 @@ Generator.prototype.readIndex = function readIndex() {

// Waiting a more flexible solution for #138
Generator.prototype.bootstrapFiles = function bootstrapFiles() {
var sass = this.compassBootstrap;
var sass = this.compass;
var source = 'styles/' + ( sass ? 's' : '' ) + 'css/';
var dest = 'app/styles/';
var mainFile = 'main.' + (sass ? 's' : '') + 'css';
Expand Down
4 changes: 2 additions & 2 deletions app/templates/styles/scss/main.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
$icon-font-path: "/bower_components/sass-bootstrap/fonts/";
<% if (compassBootstrap) { %>$icon-font-path: "/bower_components/sass-bootstrap/fonts/";

@import 'sass-bootstrap/lib/bootstrap';

.browsehappy {
<% } %>.browsehappy {
margin: 0.2em 0;
background: #ccc;
color: #000;
Expand Down
10 changes: 5 additions & 5 deletions templates/common/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = function (grunt) {
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},<% } %><% if (compassBootstrap) { %>
},<% } %><% if (compass) { %>
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports = function (grunt) {
}
},<% } %>

<% if (compassBootstrap) { %>
<% if (compass) { %>
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
Expand Down Expand Up @@ -341,17 +341,17 @@ module.exports = function (grunt) {
// Run some tasks in parallel to speed up the build process
concurrent: {
server: [<% if (coffee) { %>
'coffee:dist',<% } %><% if (compassBootstrap) { %>
'coffee:dist',<% } %><% if (compass) { %>
'compass:server'<% } else { %>
'copy:styles'<% } %>
],
test: [<% if (coffee) { %>
'coffee',<% } %><% if (compassBootstrap) { %>
'coffee',<% } %><% if (compass) { %>
'compass'<% } else { %>
'copy:styles'<% } %>
],
dist: [<% if (coffee) { %>
'coffee',<% } %><% if (compassBootstrap) { %>
'coffee',<% } %><% if (compass) { %>
'compass:dist',<% } else { %>
'copy:styles',<% } %>
'imagemin',
Expand Down
3 changes: 2 additions & 1 deletion test/test-appname-substitution.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ describe('Angular generator template mechanism', function () {
'test/spec/controllers/main.js'
];
helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});

Expand Down
22 changes: 14 additions & 8 deletions test/test-file-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ describe('Angular generator', function () {

it('should generate dotfiles', function (done) {
helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});

Expand All @@ -49,7 +50,7 @@ describe('Angular generator', function () {
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/styles/main.css',
'app/styles/main.scss',
'app/views/main.html',
['.bowerrc', /"directory": "app\/bower_components"/],
'Gruntfile.js',
Expand All @@ -61,8 +62,9 @@ describe('Angular generator', function () {
'test/spec/controllers/main.js'
];
helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});

Expand All @@ -77,7 +79,7 @@ describe('Angular generator', function () {
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/styles/main.css',
'app/styles/main.scss',
'app/views/main.html',
['.bowerrc', /"directory": "app\/bower_components"/],
'Gruntfile.js',
Expand All @@ -89,8 +91,9 @@ describe('Angular generator', function () {
'test/spec/controllers/main.coffee'
];
helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});

Expand Down Expand Up @@ -132,8 +135,9 @@ describe('Angular generator', function () {
angularGenerator = helpers.createGenerator('angular:' + generatorType, deps, [name]);

helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});
angular.run([], function (){
Expand Down Expand Up @@ -198,8 +202,9 @@ describe('Angular generator', function () {
angularView = helpers.createGenerator('angular:view', deps, ['foo']);

helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});
angular.run([], function (){
Expand All @@ -218,8 +223,9 @@ describe('Angular generator', function () {
angularView = helpers.createGenerator('angular:view', deps, ['foo/bar']);

helpers.mockPrompt(angular, {
compass: true,
bootstrap: true,
compassBoostrap: true,
compassBootstrap: true,
modules: []
});
angular.run([], function (){
Expand Down

0 comments on commit 7fac119

Please sign in to comment.