Skip to content

Commit

Permalink
0.0.7: new options, -c and ability to provide directory ignore pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
mattacular committed Sep 7, 2013
1 parent 22cf0d9 commit cc42bb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Gruntfile.js
Expand Up @@ -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']
Expand All @@ -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']
Expand Down
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -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/**/*']
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
12 changes: 8 additions & 4 deletions tasks/compass.js
Expand Up @@ -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 : '');
}
}

Expand All @@ -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]);
}
Expand All @@ -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
Expand Down
File renamed without changes.

0 comments on commit cc42bb6

Please sign in to comment.