Skip to content

Commit 7fac119

Browse files
samaxeseddiemonge
authored andcommitted
feat(gen): add Compass support to the initialization process
Twitter Bootstrap with the Compass CSS Authoring Framework question will show up only if both Compass and Bootstrap have both been enabled
1 parent 4ab6eb2 commit 7fac119

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

Diff for: app/index.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,23 @@ Generator.prototype.welcome = function welcome() {
129129
}
130130
};
131131

132+
Generator.prototype.askForCompass = function askForCompass() {
133+
var cb = this.async();
134+
135+
this.prompt([{
136+
type: 'confirm',
137+
name: 'compass',
138+
message: 'Would you like to use Sass (with Compass)?',
139+
default: true
140+
}], function (props) {
141+
this.compass = props.compass;
142+
143+
cb();
144+
}.bind(this));
145+
};
146+
132147
Generator.prototype.askForBootstrap = function askForBootstrap() {
148+
var compass = this.compass;
133149
var cb = this.async();
134150

135151
this.prompt([{
@@ -140,10 +156,10 @@ Generator.prototype.askForBootstrap = function askForBootstrap() {
140156
}, {
141157
type: 'confirm',
142158
name: 'compassBootstrap',
143-
message: 'Would you like to use the SCSS version of Twitter Bootstrap with the Compass CSS Authoring Framework?',
159+
message: 'Would you like to use the Sass version of Twitter Bootstrap?',
144160
default: true,
145161
when: function (props) {
146-
return props.bootstrap;
162+
return props.bootstrap && compass;
147163
}
148164
}], function (props) {
149165
this.bootstrap = props.bootstrap;
@@ -218,7 +234,7 @@ Generator.prototype.readIndex = function readIndex() {
218234

219235
// Waiting a more flexible solution for #138
220236
Generator.prototype.bootstrapFiles = function bootstrapFiles() {
221-
var sass = this.compassBootstrap;
237+
var sass = this.compass;
222238
var source = 'styles/' + ( sass ? 's' : '' ) + 'css/';
223239
var dest = 'app/styles/';
224240
var mainFile = 'main.' + (sass ? 's' : '') + 'css';

Diff for: app/templates/styles/scss/main.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
$icon-font-path: "/bower_components/sass-bootstrap/fonts/";
1+
<% if (compassBootstrap) { %>$icon-font-path: "/bower_components/sass-bootstrap/fonts/";
22

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

5-
.browsehappy {
5+
<% } %>.browsehappy {
66
margin: 0.2em 0;
77
background: #ccc;
88
color: #000;

Diff for: templates/common/Gruntfile.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = function (grunt) {
4545
jsTest: {
4646
files: ['test/spec/{,*/}*.js'],
4747
tasks: ['newer:jshint:test', 'karma']
48-
},<% } %><% if (compassBootstrap) { %>
48+
},<% } %><% if (compass) { %>
4949
compass: {
5050
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
5151
tasks: ['compass:server', 'autoprefixer']
@@ -187,7 +187,7 @@ module.exports = function (grunt) {
187187
}
188188
},<% } %>
189189

190-
<% if (compassBootstrap) { %>
190+
<% if (compass) { %>
191191
// Compiles Sass to CSS and generates necessary files if requested
192192
compass: {
193193
options: {
@@ -341,17 +341,17 @@ module.exports = function (grunt) {
341341
// Run some tasks in parallel to speed up the build process
342342
concurrent: {
343343
server: [<% if (coffee) { %>
344-
'coffee:dist',<% } %><% if (compassBootstrap) { %>
344+
'coffee:dist',<% } %><% if (compass) { %>
345345
'compass:server'<% } else { %>
346346
'copy:styles'<% } %>
347347
],
348348
test: [<% if (coffee) { %>
349-
'coffee',<% } %><% if (compassBootstrap) { %>
349+
'coffee',<% } %><% if (compass) { %>
350350
'compass'<% } else { %>
351351
'copy:styles'<% } %>
352352
],
353353
dist: [<% if (coffee) { %>
354-
'coffee',<% } %><% if (compassBootstrap) { %>
354+
'coffee',<% } %><% if (compass) { %>
355355
'compass:dist',<% } else { %>
356356
'copy:styles',<% } %>
357357
'imagemin',

Diff for: test/test-appname-substitution.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ describe('Angular generator template mechanism', function () {
4242
'test/spec/controllers/main.js'
4343
];
4444
helpers.mockPrompt(angular, {
45+
compass: true,
4546
bootstrap: true,
46-
compassBoostrap: true,
47+
compassBootstrap: true,
4748
modules: []
4849
});
4950

Diff for: test/test-file-creation.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ describe('Angular generator', function () {
3333

3434
it('should generate dotfiles', function (done) {
3535
helpers.mockPrompt(angular, {
36+
compass: true,
3637
bootstrap: true,
37-
compassBoostrap: true,
38+
compassBootstrap: true,
3839
modules: []
3940
});
4041

@@ -49,7 +50,7 @@ describe('Angular generator', function () {
4950
'app/404.html',
5051
'app/favicon.ico',
5152
'app/robots.txt',
52-
'app/styles/main.css',
53+
'app/styles/main.scss',
5354
'app/views/main.html',
5455
['.bowerrc', /"directory": "app\/bower_components"/],
5556
'Gruntfile.js',
@@ -61,8 +62,9 @@ describe('Angular generator', function () {
6162
'test/spec/controllers/main.js'
6263
];
6364
helpers.mockPrompt(angular, {
65+
compass: true,
6466
bootstrap: true,
65-
compassBoostrap: true,
67+
compassBootstrap: true,
6668
modules: []
6769
});
6870

@@ -77,7 +79,7 @@ describe('Angular generator', function () {
7779
'app/404.html',
7880
'app/favicon.ico',
7981
'app/robots.txt',
80-
'app/styles/main.css',
82+
'app/styles/main.scss',
8183
'app/views/main.html',
8284
['.bowerrc', /"directory": "app\/bower_components"/],
8385
'Gruntfile.js',
@@ -89,8 +91,9 @@ describe('Angular generator', function () {
8991
'test/spec/controllers/main.coffee'
9092
];
9193
helpers.mockPrompt(angular, {
94+
compass: true,
9295
bootstrap: true,
93-
compassBoostrap: true,
96+
compassBootstrap: true,
9497
modules: []
9598
});
9699

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

134137
helpers.mockPrompt(angular, {
138+
compass: true,
135139
bootstrap: true,
136-
compassBoostrap: true,
140+
compassBootstrap: true,
137141
modules: []
138142
});
139143
angular.run([], function (){
@@ -198,8 +202,9 @@ describe('Angular generator', function () {
198202
angularView = helpers.createGenerator('angular:view', deps, ['foo']);
199203

200204
helpers.mockPrompt(angular, {
205+
compass: true,
201206
bootstrap: true,
202-
compassBoostrap: true,
207+
compassBootstrap: true,
203208
modules: []
204209
});
205210
angular.run([], function (){
@@ -218,8 +223,9 @@ describe('Angular generator', function () {
218223
angularView = helpers.createGenerator('angular:view', deps, ['foo/bar']);
219224

220225
helpers.mockPrompt(angular, {
226+
compass: true,
221227
bootstrap: true,
222-
compassBoostrap: true,
228+
compassBootstrap: true,
223229
modules: []
224230
});
225231
angular.run([], function (){

0 commit comments

Comments
 (0)