Browse files

0.0.7: new options, -c and ability to provide directory ignore pattern

  • Loading branch information...
1 parent 22cf0d9 commit cc42bb6da70d999f521246b840cb748e7bfb9f73 @mattacular committed Sep 7, 2013
Showing with 17 additions and 9 deletions.
  1. +4 −2 Gruntfile.js
  2. +4 −2 README.md
  3. +1 −1 package.json
  4. +8 −4 tasks/compass.js
  5. 0 tests/modules/test-all-options/{config.rb → prod.rb}
View
6 Gruntfile.js
@@ -22,7 +22,8 @@ module.exports = function (grunt) {
options: {
css_dir: 'tmp',
sass_dir: 'sass',
- output_style: 'compressed'
+ output_style: 'compressed',
+ c: 'prod.rb'
},
files: {
src: ['tests/modules/test-all-options']
@@ -48,7 +49,8 @@ module.exports = function (grunt) {
options: {
css_dir: 'expected',
sass_dir: 'sass',
- output_style: 'compressed'
+ output_style: 'compressed',
+ c: 'prod.rb'
},
files: {
src: ['tests/modules/test-all-options']
View
6 README.md
@@ -27,7 +27,9 @@ This allows you to use the 'compass' task to specify targets!
css_dir: 'css',
sass_dir: 'sass',
javascripts_dir: 'js',
- output_style: (grunt.option('env') === 'prod') ? 'compressed' : 'expanded'
+ output_style: (grunt.option('env') === 'prod') ? 'compressed' : 'expanded',
+ c: 'prod.rb' // look for something other than config.rb and use it to compile
+ ignore_pattern: /sass|css|js|img|images|inc|includes/, // paths you know won't contain a compass config
},
files: {
src: ['sites/all/modules/**/*']
@@ -42,7 +44,7 @@ The task will look for a 'config.rb' file in each target directory found. It wil
grunt compass:modules --env=prod
```
-Would execute each config.rb found anywhere inside "sites/all/modules" with:
+Would compile each prod.rb found anywhere inside "sites/all/modules" by executing this command:
```bash
compass compile --sass-dir=sass --javascripts-dir=js --css-dir=css --output-style=compressed
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "grunt-compass-compiler",
"description": "Grunt task to compile multiple Compass projects",
- "version": "0.0.6",
+ "version": "0.0.7",
"homepage": "https://github.com/mattacular/grunt-compass-compiler",
"author": {
"name": "Matt Stills",
View
12 tasks/compass.js
@@ -25,7 +25,7 @@ module.exports = function (grunt) {
value = opts[option];
if (value) {
- retVal += ' --' + option.replace('_', '-') + ((typeof value === 'string') ? '=' + value : '');
+ retVal += (option !== 'c' ? ' --' : ' -') + option.replace('_', '-') + ((typeof value === 'string') ? (option !== 'c' ? '=' : ' ') + value : '');
}
}
@@ -38,21 +38,24 @@ module.exports = function (grunt) {
output_style: false,
sass_dir: false,
css_dir: false,
- javascripts_dir: false
+ javascripts_dir: false,
+ ignore_pattern: /sass|css|js|img|inc[(?:ludes)]|template[s]?/,
+ c: false
}),
compilerOptions = false,
targets = [],
done = this.async(),
+ configFile = options.c || 'config.rb',
files, childProcess, targetQueue;
// gather a list of targets with a 'config.rb' from all the file matches found by Grunt's globbing engine
this.files.forEach(function (f) {
for (var i = 0; i < f.src.length; i += 1) {
// filter out folders that don't have a config.rb (ignoring common sub-folders to speed things up)
- if (!f.src[i].match(/sass|css|js|img|inc[(?:ludes)]|template[s]?/) && grunt.file.isDir(f.src[i])) {
+ if (!f.src[i].match(options.ignore_pattern) && grunt.file.isDir(f.src[i])) {
files = fs.readdirSync(f.src[i]);
- if (_.indexOf(files, 'config.rb') !== -1) {
+ if (_.indexOf(files, configFile) !== -1) {
// contains config.rb, add it to the list of compile targets
targets.push(f.src[i]);
}
@@ -61,6 +64,7 @@ module.exports = function (grunt) {
});
// transform task options into arguments compatible with the Compass CLI utility
+ delete options.ignore_pattern;
compilerOptions = transformOptions(options);
// begin
View
0 tests/modules/test-all-options/config.rb → tests/modules/test-all-options/prod.rb
File renamed without changes.

0 comments on commit cc42bb6

Please sign in to comment.