From 6c77c360f743e7970135b9bacafdfd917b623872 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Wed, 17 Apr 2013 22:59:06 +0100 Subject: [PATCH 01/40] fixed bug which failed grunt task when outputting JSON and set to fail when duplicates are found even though no duplicates were found. (#3). --- gruntfile.js | 12 ++++++++++++ tasks/csscss.js | 13 +++++++++++-- test/example/no-duplicates.css | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 test/example/no-duplicates.css diff --git a/gruntfile.js b/gruntfile.js index 01e2bc4..da8a137 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -36,6 +36,18 @@ module.exports = function(grunt) { }, dist: { src: ['test/example/style.css', 'test/example/shorthand.css', 'test/example/compass/sass/screen.scss'] + }, + + /** + * Tests that the grunt task doesn't fail when outputting JSON and the failWhenDuplicates + * option is set to true. + */ + outputJsonTest: { + options: { + failWhenDuplicates: true, + outputJson: true + }, + src: ['test/example/no-duplicates.css'] } } diff --git a/tasks/csscss.js b/tasks/csscss.js index 30800b1..249cd4d 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -129,8 +129,17 @@ module.exports = function(grunt) { * displays the output and error streams via the parent process. */ child.stdout.on('data', function(buf) { - grunt.log.writeln(String(buf)); - hasDuplicates = true; + var output = String(buf); + grunt.log.writeln(output); + + /** + * When outputting JSON from CSSCSS an empty array will be outputted, this + * should be ignored and shouldn't cause the grunt task to fail if no other + * duplicates are found. + */ + if (!(options.outputJson && JSON.parse(output).length === 0)) { + hasDuplicates = true; + } }); child.stderr.on('data', function(buf) { diff --git a/test/example/no-duplicates.css b/test/example/no-duplicates.css new file mode 100644 index 0000000..4762979 --- /dev/null +++ b/test/example/no-duplicates.css @@ -0,0 +1,16 @@ +.rule-a { + font-size: 1em; + margin: 1em; + padding: 0; +} + +.rule-b { + background-color: #ff0; + margin: 0; + padding: 0; +} + +.rule-c { + border: 1px solid #f0f; + margin: 14px; +} From b03a487ff6334461c872e838ae099c5fcdf2fdd8 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Wed, 17 Apr 2013 23:05:17 +0100 Subject: [PATCH 02/40] moved the construction of arguments from the options to outside the file loop so the same code with the same outcome isn't run multiple times. --- tasks/csscss.js | 148 ++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/tasks/csscss.js b/tasks/csscss.js index 249cd4d..036e915 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -20,103 +20,105 @@ module.exports = function(grunt) { var done = this.async(); - grunt.util.async.forEachSeries(this.data.src, function(f, next) { - var args = []; + var args = []; - /** - * Outputs the rules that have been matched. - */ - if (options.verbose) { - args.push('-v'); - } + /** + * Outputs the rules that have been matched. + */ + if (options.verbose) { + args.push('-v'); + } - /** - * Flag indicating whether the output should be colorized. This is true by - * default. - */ - if (options.colorize === false) { - args.push('--no-color'); - } + /** + * Flag indicating whether the output should be colorized. This is true by + * default. + */ + if (options.colorize === false) { + args.push('--no-color'); + } - /** - * Enables Compass extensions when parsing Sass files. This argument is not - * set if the compassConfig property has been defined. - */ - if (options.compass && !options.compassConfig) { - args.push('--compass'); - } + /** + * Enables Compass extensions when parsing Sass files. This argument is not + * set if the compassConfig property has been defined. + */ + if (options.compass && !options.compassConfig) { + args.push('--compass'); + } - /** - * Enables Compass extensions when parsing Sass files and specifies the path - * to the config file. - */ - if (options.compassConfig) { - args.push('--compass-with-config'); - args.push(options.compassConfig); - } + /** + * Enables Compass extensions when parsing Sass files and specifies the path + * to the config file. + */ + if (options.compassConfig) { + args.push('--compass-with-config'); + args.push(options.compassConfig); + } - /** - * Returns analysis in JSON format. - */ - if (options.outputJson) { - args.push('-j'); - } + /** + * Returns analysis in JSON format. + */ + if (options.outputJson) { + args.push('-j'); + } - /** - * Sets the minimum number of rules before a match is found. - */ - if (options.minMatch) { - args.push('-n'); - args.push(options.minMatch); - } + /** + * Sets the minimum number of rules before a match is found. + */ + if (options.minMatch) { + args.push('-n'); + args.push(options.minMatch); + } - /** - * Sets which properties should be ignored. - */ - if (options.ignoreProperties) { - args.push('--ignore-properties'); - args.push(options.ignoreProperties); - } + /** + * Sets which properties should be ignored. + */ + if (options.ignoreProperties) { + args.push('--ignore-properties'); + args.push(options.ignoreProperties); + } - /** - * Sets which selectors should be ignored. - */ - if (options.ignoreSelectors) { - args.push('--ignore-selectors'); - args.push(options.ignoreSelectors); - } + /** + * Sets which selectors should be ignored. + */ + if (options.ignoreSelectors) { + args.push('--ignore-selectors'); + args.push(options.ignoreSelectors); + } - /** - * Sets whether parser errors should be outputted. - */ - if (options.showParserErrors) { - args.push('--show-parser-errors'); - } + /** + * Sets whether parser errors should be outputted. + */ + if (options.showParserErrors) { + args.push('--show-parser-errors'); + } - /** - * Sets whether shorthand should be matched. - */ - if (options.shorthand === false) { - args.push('--no-match-shorthand'); - } + /** + * Sets whether shorthand should be matched. + */ + if (options.shorthand === false) { + args.push('--no-match-shorthand'); + } + + grunt.util.async.forEachSeries(this.data.src, function(f, next) { /** - * adds path to file, to be analysed, as an argument. + * adds the file path as the final argument, this goes into a new array so + * the file doesn't get used in the next iteration. */ - args.push(f); + var cmdArgs = args.concat([f]); /** * Outputs the file that is being analysed. */ grunt.log.writeln(f); - grunt.verbose.writeln('csscss ' + args.join(' ')); + grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); /** * Executes the csscss command. */ var child = grunt.util.spawn({ cmd: 'csscss', - args: args + args: cmdArgs }, function(error, result, code) { if (code === 127) { return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); From 92e3edb0501adb06cdc3a05135c8a8cbd968f267 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Wed, 17 Apr 2013 23:11:00 +0100 Subject: [PATCH 03/40] added release notes for v0.3.1. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5c44c42..50356fb 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,11 @@ csscss: { ## Release History +### 0.3.1 (April 17th 2013) + +* Fixed bug with grunt task failing when CSSCSS outputs JSON even though duplicates weren't found. ([#3](https://github.com/peterkeating/grunt-csscss/issues/3)) +* Performance improvements by moving re-used argument construction outside the file loop. + ### 0.3.0 (April 16th 2013) * Added `failWhenDuplicates` option to fail Grunt task when CSSCSS finds rule sets with duplicate declarations. ([#2](https://github.com/peterkeating/grunt-csscss/issues/2)) From 8fa6a161dc4d3507b1a8fc20b987ba59d892eab6 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Wed, 17 Apr 2013 23:11:36 +0100 Subject: [PATCH 04/40] updated to version to v0.3.1. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4595981..8139e3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.3.0", + "version": "0.3.1", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 3ba53db4e84fb2559d1894c07843cfb74331e9ef Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 09:29:52 +0100 Subject: [PATCH 05/40] updated the compassConfig option so it uses --compass --require instead of --compass-with-config which is now deprecated. --- gruntfile.js | 12 +++++++++--- tasks/csscss.js | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index da8a137..5b8cceb 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -26,16 +26,22 @@ module.exports = function(grunt) { verbose: true, outputJson: false, minMatch: 2, - compass: true, ignoreProperties: 'padding', ignoreSelectors: '.rule-a', showParserErrors: true, shorthand: false, - compassConfig: 'test/example/compass/config.rb', failWhenDuplicates: false }, dist: { - src: ['test/example/style.css', 'test/example/shorthand.css', 'test/example/compass/sass/screen.scss'] + src: ['test/example/style.css', 'test/example/shorthand.css'] + }, + + compass: { + options: { + compassConfig: 'test/example/compass/config.rb', + compass: true + }, + src: ['test/example/compass/sass/screen.scss'] }, /** diff --git a/tasks/csscss.js b/tasks/csscss.js index 036e915..7e97b0a 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -50,7 +50,8 @@ module.exports = function(grunt) { * to the config file. */ if (options.compassConfig) { - args.push('--compass-with-config'); + args.push('--compass'); + args.push('--require'); args.push(options.compassConfig); } From 51e4cb2567a65f957b82b35545ee9e7463b36af2 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 09:52:57 +0100 Subject: [PATCH 06/40] implemented the --require argument with the require option. The compassConfig option will be ignored if the require option is in use. --- gruntfile.js | 3 +-- tasks/csscss.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 5b8cceb..35e2d31 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -38,8 +38,7 @@ module.exports = function(grunt) { compass: { options: { - compassConfig: 'test/example/compass/config.rb', - compass: true + require: 'test/example/compass/config.rb' }, src: ['test/example/compass/sass/screen.scss'] }, diff --git a/tasks/csscss.js b/tasks/csscss.js index 7e97b0a..4b25230 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -48,13 +48,25 @@ module.exports = function(grunt) { /** * Enables Compass extensions when parsing Sass files and specifies the path * to the config file. + * The compassConfig option is deprecated and will be removed in a future release. + * The require option should be used instead. */ - if (options.compassConfig) { + if (options.compassConfig && !options.require) { args.push('--compass'); args.push('--require'); args.push(options.compassConfig); } + /** + * Enables Compass extensions when parsing Sass files and specifies the path + * to the config file. + */ + if (options.require) { + args.push('--compass'); + args.push('--require'); + args.push(options.require); + } + /** * Returns analysis in JSON format. */ From 56b1d5d3f2f7e4199e098d68dd27ff6bbe6292ae Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 09:54:42 +0100 Subject: [PATCH 07/40] added message that compassConfig option is deprecated recommending the use of the require option instead. --- tasks/csscss.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/csscss.js b/tasks/csscss.js index 4b25230..ea4053d 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -55,6 +55,8 @@ module.exports = function(grunt) { args.push('--compass'); args.push('--require'); args.push(options.compassConfig); + + grunt.log.writeln('WARNING: compassConifg is DEPRECATED, please use the "require" option'); } /** From 2e31a5e9346e63b7df26887cd2bae0fb61fc9de7 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 10:03:46 +0100 Subject: [PATCH 08/40] updated documentation to include 'require' option and note that the 'compassConfig' option is deprecated. --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 50356fb..9f099d1 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,14 @@ Enables Compass extensions when parsing Sass. *[Compass](http://compass-style.org/) must be installed in order to use this option.* -### compassConfig +### compassConfig - DEPRECATED Type: `String` Enables Compass extension and specifies path to a config file. +**This option is deprecated, the require option should be used.** + *[Compass](http://compass-style.org/) must be installed in order to use this option.* ### failWhenDuplicates @@ -98,6 +100,14 @@ Default: `false` Outputs parser errors. +### require + +Type: `string` + +Path to a ruby file that is loaded before running CSSCSS. + +*[Compass](http://compass-style.org/) must be installed in order to use this option.* + ### verbose Type: `Boolean` From e2bb1ba68f316a5cdb299aadbeb5adbf9ec0b36b Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 10:12:27 +0100 Subject: [PATCH 09/40] implemented the --ignore-sass-mixins argument. --- gruntfile.js | 6 +++++- tasks/csscss.js | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 35e2d31..5271056 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -36,9 +36,13 @@ module.exports = function(grunt) { src: ['test/example/style.css', 'test/example/shorthand.css'] }, + /** + * Tests running the grunt task in a Compass setup. + */ compass: { options: { - require: 'test/example/compass/config.rb' + require: 'test/example/compass/config.rb', + ignoreSassMixins: true }, src: ['test/example/compass/sass/screen.scss'] }, diff --git a/tasks/csscss.js b/tasks/csscss.js index ea4053d..27a4946 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -92,6 +92,13 @@ module.exports = function(grunt) { args.push(options.ignoreProperties); } + /** + * Sets whether Sass mixins should be ignored. + */ + if (options.ignoreSassMixins) { + args.push('--ignore-sass-mixins'); + } + /** * Sets which selectors should be ignored. */ From 9ff440076aaedb1dc019d9f480564b874c71021a Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 10:13:01 +0100 Subject: [PATCH 10/40] added documentation for the ignoreSassMixins option. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9f099d1..3a1841c 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,15 @@ Type: `String` Comma seperated list of CSS properties that should be ignored when finding matches. +### ignoreSassMixins + +Type: `Boolean` +Default: `false` + +Flag indicating whether matches in Sass mixins should be ignored. + +*This is an experimental feature.* + ### ignoreSelectors Type: `String` From 0aac5d6630375f92fe361ae4303bdc4689e03083 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 10:20:22 +0100 Subject: [PATCH 11/40] updated releases notes. --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a1841c..ab3afbd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Grunt task that runs [CSSCSS](http://zmoazeni.github.io/csscss/), a CSS redundan CSSCSS runs on Ruby (`v1.9.x` and up), to check Ruby is installed on your machine use `ruby -v`. To install the CSSCSS gem run `gem install csscss` command, this will grab the latest version. -Currently grunt-csscss handles all the features for CSSCSS that are available with version **1.2.0**. +Currently grunt-csscss handles all the features for CSSCSS that are available with version **1.3.1**. ## Getting Started @@ -192,6 +192,13 @@ csscss: { ## Release History +### 0.4.0 (April 21st 2013) + +* Added `ignoreSassMixins` option to ignore matches in Sass mixins. +* Added `require` option for loading Ruby file before running CSSCSS. +* Updated the `compassConfig` option to use the `--require` argument instead of the now deprecated `--compass-with-config` argument. +* Deprecated `compassConfig` option. + ### 0.3.1 (April 17th 2013) * Fixed bug with grunt task failing when CSSCSS outputs JSON even though duplicates weren't found. ([#3](https://github.com/peterkeating/grunt-csscss/issues/3)) From da16f9e893a31e71755f786645c24d0f1f8806cf Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sun, 21 Apr 2013 10:20:48 +0100 Subject: [PATCH 12/40] updated package to v0.4.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8139e3f..2b92d44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.3.1", + "version": "0.4.0", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 70da5369bd71d34627079c1757028dd31aec0d78 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 22 Apr 2013 18:08:13 +0200 Subject: [PATCH 13/40] updated compass example to use require option. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab3afbd..86e1d0a 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ Example of using CSSCSS to analyze Sass files that are converted using Compass. ```js csscss: { options: { - compassConfig: 'my/config/file/config.rb' + require: 'my/config/file.rb' }, dist: { src: ['sass/style.scss'] From 8a788cc8787e938814030ccf13a7c28b5d8ac777 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 23 Apr 2013 15:20:34 +0100 Subject: [PATCH 14/40] fixed typo in deprecated message when using compassConfig option. (#4) --- tasks/csscss.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/csscss.js b/tasks/csscss.js index 27a4946..304b7d1 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -56,7 +56,7 @@ module.exports = function(grunt) { args.push('--require'); args.push(options.compassConfig); - grunt.log.writeln('WARNING: compassConifg is DEPRECATED, please use the "require" option'); + grunt.log.writeln('WARNING: compassConfig is DEPRECATED, please use the "require" option.'); } /** From afb27b710e90adde497e047445ab4759f8be3c92 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 20 May 2013 09:58:37 +0100 Subject: [PATCH 15/40] fixed typo in options link. (#5) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86e1d0a..c8749d7 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ csscss: { ### Specifying Options -Example of using the [options](https://github.com/peterkeating/grunt-csscss/edit/master/README.md#options). +Example of using the [options](https://github.com/peterkeating/grunt-csscss#options). ```js csscss: { From 0f2f5e066d781b7f3ba180e9afc5ce8088505b18 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 20 May 2013 11:31:58 +0100 Subject: [PATCH 16/40] added bundleExec option to enable running CSSCSS in the context of a bundle. (#6). --- README.md | 7 +++++++ tasks/csscss.js | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8749d7..0897fe7 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,13 @@ grunt.loadNpmTasks('grunt-csscss'); ``` ## Options +### bundleExec + +Type: `Boolean` +Default: `false` + +Run CSSCSS with [bundle exec](http://gembundler.com/). + ### colorize Type: `Boolean` diff --git a/tasks/csscss.js b/tasks/csscss.js index 304b7d1..e1d059a 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -22,6 +22,15 @@ module.exports = function(grunt) { var args = []; + args.push('csscss'); + + /** + * Flag indicating whether CSSCSS should be run in the context of a bundle. + */ + if (options.bundleExec) { + args.unshift('bundle', 'exec'); + } + /** * Outputs the rules that have been matched. */ @@ -139,7 +148,7 @@ module.exports = function(grunt) { * Executes the csscss command. */ var child = grunt.util.spawn({ - cmd: 'csscss', + cmd: cmdArgs.shift(), args: cmdArgs }, function(error, result, code) { if (code === 127) { From b4111b3cd6bb92884e29215a35a99cc19fd5082c Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 20 May 2013 11:34:21 +0100 Subject: [PATCH 17/40] updated release history to include v0.5.0 details. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0897fe7..03c9776 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,11 @@ csscss: { ## Release History +### 0.5.0 (Unreleased) + +* Fixed typos in the documentation ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) +* Added `bundleExec` option to run CSSCSS in the context of a bundle. ([#6](https://github.com/peterkeating/grunt-csscss/issues/6)) + ### 0.4.0 (April 21st 2013) * Added `ignoreSassMixins` option to ignore matches in Sass mixins. From a016446b5b9508415c5726cd67dae944c8b81642 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 20 May 2013 22:16:01 +0100 Subject: [PATCH 18/40] added test of a glob pattern. --- gruntfile.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gruntfile.js b/gruntfile.js index 5271056..b9ed37b 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -57,6 +57,13 @@ module.exports = function(grunt) { outputJson: true }, src: ['test/example/no-duplicates.css'] + }, + + /** + * Tests that CSSCSS handles a glob pattern. + */ + globbing: { + src: ['test/example/*.css'] } } From 02f691790939e98f10cc9f6acf915f5c948df57d Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 20 May 2013 22:42:37 +0100 Subject: [PATCH 19/40] added example of globbing Sass files. #7. --- gruntfile.js | 2 +- test/example/_scss/another.scss | 19 +++++++++++++++++++ test/example/_scss/screen.scss | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/example/_scss/another.scss create mode 100644 test/example/_scss/screen.scss diff --git a/gruntfile.js b/gruntfile.js index b9ed37b..8a35d2c 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -63,7 +63,7 @@ module.exports = function(grunt) { * Tests that CSSCSS handles a glob pattern. */ globbing: { - src: ['test/example/*.css'] + src: ['test/example/_scss/*.scss'] } } diff --git a/test/example/_scss/another.scss b/test/example/_scss/another.scss new file mode 100644 index 0000000..ae43596 --- /dev/null +++ b/test/example/_scss/another.scss @@ -0,0 +1,19 @@ + +$color: #000; + +.rule-d { + border: 1px solid $color; + margin: 0; + padding: 0; +} + +.rule-e { + border: 1px solid $color; + margin: 0; + padding: 0; +} + +.rule-f { + border: 1px solid $color; + margin: 0; +} diff --git a/test/example/_scss/screen.scss b/test/example/_scss/screen.scss new file mode 100644 index 0000000..0f02de8 --- /dev/null +++ b/test/example/_scss/screen.scss @@ -0,0 +1,18 @@ +$color: #000; + +.rule-a { + border: 1px solid $color; + margin: 0; + padding: 0; +} + +.rule-b { + border: 1px solid $color; + margin: 0; + padding: 0; +} + +.rule-c { + border: 1px solid $color; + margin: 0; +} From 61dc942858e6fe7e817c5e4a55ae47d620d0ebb3 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 21 May 2013 11:12:54 +0100 Subject: [PATCH 20/40] added the ability to specify glob patterns in the src option. (#7). --- package.json | 3 + tasks/csscss.js | 143 +++++++++++++++++++++++++++++------------------- 2 files changed, 91 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 2b92d44..5e9c3ea 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,9 @@ "scripts": { "test": "grunt" }, + "dependencies": { + "glob": "3.2.1" + }, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-jshint": "~0.4.3" diff --git a/tasks/csscss.js b/tasks/csscss.js index e1d059a..b41febc 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -7,6 +7,77 @@ module.exports = function(grunt) { grunt.registerMultiTask('csscss', 'CSSCSS redundancy analyzer.', function() { + + var glob = require('glob'); + + /** + * Asynchronously loops through the provided files and puts them through the + * CSSCSS tool. + */ + function analyzeFiles(files) { + grunt.util.async.forEachSeries(files, function(f, next) { + + /** + * adds the file path as the final argument, this goes into a new array so + * the file doesn't get used in the next iteration. + */ + var cmdArgs = args.concat([f]); + + /** + * Outputs the file that is being analysed. + */ + grunt.log.writeln(f); + grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); + + /** + * Executes the csscss command. + */ + var child = grunt.util.spawn({ + cmd: cmdArgs.shift(), + args: cmdArgs + }, function(error, result, code) { + if (code === 127) { + return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); + } + + next(error); + }); + + /** + * displays the output and error streams via the parent process. + */ + child.stdout.on('data', function(buf) { + var output = String(buf); + grunt.log.writeln(output); + + /** + * When outputting JSON from CSSCSS an empty array will be outputted, this + * should be ignored and shouldn't cause the grunt task to fail if no other + * duplicates are found. + */ + if (!(options.outputJson && JSON.parse(output).length === 0)) { + hasDuplicates = true; + } + }); + + child.stderr.on('data', function(buf) { + grunt.log.writeln(String(buf)); + }); + + }, function () { + + /** + * If instructed to fail when a match happens and matches found lets fail + * the grunt build. + */ + if (options.failWhenDuplicates && hasDuplicates) { + grunt.fail.warn("Failed due to matches found by CSSCSS."); + } + + done(); + }); + } + /** * Retrieves defined options. */ @@ -17,9 +88,11 @@ module.exports = function(grunt) { * Flag for whether any duplicates were found by CSSCSS. */ var hasDuplicates = false; - var done = this.async(); + /** + * Contains the arguments that are to be passed to CSSCSS. + */ var args = []; args.push('csscss'); @@ -130,68 +203,28 @@ module.exports = function(grunt) { args.push('--no-match-shorthand'); } - grunt.util.async.forEachSeries(this.data.src, function(f, next) { - - /** - * adds the file path as the final argument, this goes into a new array so - * the file doesn't get used in the next iteration. - */ - var cmdArgs = args.concat([f]); - - /** - * Outputs the file that is being analysed. - */ - grunt.log.writeln(f); - grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); - - /** - * Executes the csscss command. - */ - var child = grunt.util.spawn({ - cmd: cmdArgs.shift(), - args: cmdArgs - }, function(error, result, code) { - if (code === 127) { - return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); - } - - next(error); - }); - - /** - * displays the output and error streams via the parent process. - */ - child.stdout.on('data', function(buf) { - var output = String(buf); - grunt.log.writeln(output); + /** + * Array of files that are to be analyzed by CSSCSS. + */ + var filesToBeAnalyzed = []; + grunt.util.async.forEachSeries(this.data.src, function(f, next) { + glob(f, options, function (er, files) { /** - * When outputting JSON from CSSCSS an empty array will be outputted, this - * should be ignored and shouldn't cause the grunt task to fail if no other - * duplicates are found. + * Loops through the matched files and ensures that each file is only + * processed once. */ - if (!(options.outputJson && JSON.parse(output).length === 0)) { - hasDuplicates = true; + for (var j = 0; j < files.length; j++) { + if (filesToBeAnalyzed.indexOf(files[j]) < 0) { + filesToBeAnalyzed.push(files[j]); + } } - }); - child.stderr.on('data', function(buf) { - grunt.log.writeln(String(buf)); + next(); }); - }, function () { - - /** - * If instructed to fail when a match happens and matches found lets fail - * the grunt build. - */ - if (options.failWhenDuplicates && hasDuplicates) { - grunt.fail.warn("Failed due to matches found by CSSCSS."); - } - - done(); + analyzeFiles(filesToBeAnalyzed); }); - }); }; From 19fe057b20ec2cc187152d21243d45b6a804cd0d Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 21 May 2013 13:24:18 +0100 Subject: [PATCH 21/40] added example to README of using a glob pattern. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 03c9776..2544061 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,18 @@ csscss: { } ``` +### Specifying Files with Glob Pattern + +Example of using a glob pattern to target many files that should be analysed by CSSCSS. The example below will analyse all the files in the `css` directory that have an extension of `.css`. + +```js +csscss: { + dist: { + src: ['css/*.css'] + } +} +``` + ## Release History ### 0.5.0 (Unreleased) From 9d38a6814a688a3b0f95f2d865150b8131e78d2e Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 21 May 2013 13:25:33 +0100 Subject: [PATCH 22/40] updated release notes. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2544061..ddbed43 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,8 @@ csscss: { ### 0.5.0 (Unreleased) -* Fixed typos in the documentation ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) +* Specifying which files CSSCSS should analyse now supports glob patterns. ([#7](https://github.com/peterkeating/grunt-csscss/issues/7)) +* Fixed typos in the documentation. ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) * Added `bundleExec` option to run CSSCSS in the context of a bundle. ([#6](https://github.com/peterkeating/grunt-csscss/issues/6)) ### 0.4.0 (April 21st 2013) From e41ec4ba0dc65876a2aa3bb739933b4e108e0906 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 21 May 2013 13:27:39 +0100 Subject: [PATCH 23/40] removed previous globbing example files, now the glob example targets existing CSS files. --- gruntfile.js | 2 +- test/example/_scss/another.scss | 19 ------------------- test/example/_scss/screen.scss | 18 ------------------ 3 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 test/example/_scss/another.scss delete mode 100644 test/example/_scss/screen.scss diff --git a/gruntfile.js b/gruntfile.js index 8a35d2c..b9ed37b 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -63,7 +63,7 @@ module.exports = function(grunt) { * Tests that CSSCSS handles a glob pattern. */ globbing: { - src: ['test/example/_scss/*.scss'] + src: ['test/example/*.css'] } } diff --git a/test/example/_scss/another.scss b/test/example/_scss/another.scss deleted file mode 100644 index ae43596..0000000 --- a/test/example/_scss/another.scss +++ /dev/null @@ -1,19 +0,0 @@ - -$color: #000; - -.rule-d { - border: 1px solid $color; - margin: 0; - padding: 0; -} - -.rule-e { - border: 1px solid $color; - margin: 0; - padding: 0; -} - -.rule-f { - border: 1px solid $color; - margin: 0; -} diff --git a/test/example/_scss/screen.scss b/test/example/_scss/screen.scss deleted file mode 100644 index 0f02de8..0000000 --- a/test/example/_scss/screen.scss +++ /dev/null @@ -1,18 +0,0 @@ -$color: #000; - -.rule-a { - border: 1px solid $color; - margin: 0; - padding: 0; -} - -.rule-b { - border: 1px solid $color; - margin: 0; - padding: 0; -} - -.rule-c { - border: 1px solid $color; - margin: 0; -} From 300c97f4b1a4c1223a1a98895f53e1639e98d7c2 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 4 Jun 2013 21:15:49 +0100 Subject: [PATCH 24/40] updated to package to v0.5.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e9c3ea..31bc5ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.4.0", + "version": "0.5.0", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 7c5ea0d845443cc26656dc868c554f5a05e37c84 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Tue, 4 Jun 2013 21:18:00 +0100 Subject: [PATCH 25/40] updated release history to include release date of v0.5.0. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddbed43..fc07e7c 100644 --- a/README.md +++ b/README.md @@ -211,7 +211,7 @@ csscss: { ## Release History -### 0.5.0 (Unreleased) +### 0.5.0 (June 4th 2013) * Specifying which files CSSCSS should analyse now supports glob patterns. ([#7](https://github.com/peterkeating/grunt-csscss/issues/7)) * Fixed typos in the documentation. ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) From 0aa4a6753e1f59e84cf717ac3ccc205cda785410 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 8 Aug 2013 23:01:32 +0100 Subject: [PATCH 26/40] refactored task to use recommended this.files instead of this.data for accessing files to be analyzed. (#8) --- package.json | 3 -- tasks/csscss.js | 117 +++++++++++++++++++++--------------------------- 2 files changed, 52 insertions(+), 68 deletions(-) diff --git a/package.json b/package.json index 31bc5ad..b3707c2 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,6 @@ "scripts": { "test": "grunt" }, - "dependencies": { - "glob": "3.2.1" - }, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-jshint": "~0.4.3" diff --git a/tasks/csscss.js b/tasks/csscss.js index b41febc..fa0cb3a 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -8,64 +8,72 @@ module.exports = function(grunt) { grunt.registerMultiTask('csscss', 'CSSCSS redundancy analyzer.', function() { - var glob = require('glob'); - /** * Asynchronously loops through the provided files and puts them through the * CSSCSS tool. */ - function analyzeFiles(files) { - grunt.util.async.forEachSeries(files, function(f, next) { - - /** - * adds the file path as the final argument, this goes into a new array so - * the file doesn't get used in the next iteration. - */ - var cmdArgs = args.concat([f]); + function analyze(files) { + /** + * Loops over all the files specified in the src array. + */ + grunt.util.async.forEachSeries(files, function(file, next) { /** - * Outputs the file that is being analysed. + * Loops over all the matches files in the src in case there are multiple. */ - grunt.log.writeln(f); - grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); + grunt.util.async.forEachSeries(file.src, function (fileToBeAnalyzed, innerNext) { - /** - * Executes the csscss command. - */ - var child = grunt.util.spawn({ - cmd: cmdArgs.shift(), - args: cmdArgs - }, function(error, result, code) { - if (code === 127) { - return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); - } - - next(error); - }); + /** + * adds the file path as the final argument, this goes into a new array so + * the file doesn't get used in the next iteration. + */ + var cmdArgs = args.concat([fileToBeAnalyzed]); - /** - * displays the output and error streams via the parent process. - */ - child.stdout.on('data', function(buf) { - var output = String(buf); - grunt.log.writeln(output); + /** + * Outputs the file that is being analysed. + */ + grunt.log.writeln(fileToBeAnalyzed); + grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); /** - * When outputting JSON from CSSCSS an empty array will be outputted, this - * should be ignored and shouldn't cause the grunt task to fail if no other - * duplicates are found. + * Executes the csscss command. */ - if (!(options.outputJson && JSON.parse(output).length === 0)) { - hasDuplicates = true; - } - }); + var child = grunt.util.spawn({ + cmd: cmdArgs.shift(), + args: cmdArgs + }, function(error, result, code) { + if (code === 127) { + return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); + } - child.stderr.on('data', function(buf) { - grunt.log.writeln(String(buf)); - }); + innerNext(error); + }); + /** + * displays the output and error streams via the parent process. + */ + child.stdout.on('data', function(buf) { + var output = String(buf); + grunt.log.writeln(output); + + /** + * When outputting JSON from CSSCSS an empty array will be outputted, this + * should be ignored and shouldn't cause the grunt task to fail if no other + * duplicates are found. + */ + if (!(options.outputJson && JSON.parse(output).length === 0)) { + hasDuplicates = true; + } + }); + + child.stderr.on('data', function(buf) { + grunt.log.writeln(String(buf)); + }); + + }, function () { + next(); + }); }, function () { - /** * If instructed to fail when a match happens and matches found lets fail * the grunt build. @@ -203,28 +211,7 @@ module.exports = function(grunt) { args.push('--no-match-shorthand'); } - /** - * Array of files that are to be analyzed by CSSCSS. - */ - var filesToBeAnalyzed = []; - - grunt.util.async.forEachSeries(this.data.src, function(f, next) { - glob(f, options, function (er, files) { - /** - * Loops through the matched files and ensures that each file is only - * processed once. - */ - for (var j = 0; j < files.length; j++) { - if (filesToBeAnalyzed.indexOf(files[j]) < 0) { - filesToBeAnalyzed.push(files[j]); - } - } - - next(); - }); - }, function () { - analyzeFiles(filesToBeAnalyzed); - }); + analyze(this.files); }); }; From 321d8fe8b9ba8498a8f170414d469d9731aa87fa Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Fri, 9 Aug 2013 00:51:37 +0100 Subject: [PATCH 27/40] added the ability to write the output of CSSCSS to a local file. (#8). --- .gitignore | 3 +++ README.md | 15 +++++++++++++++ gruntfile.js | 13 ++++++++++++- tasks/csscss.js | 41 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 12eb472..611cbac 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ npm-debug.log # directory creating by the Sass conversion which is done when testing grunt task # against Compass stylesheets. .sass-cache/ + +# convenient directory for storing files that should be ignored by Git. +ignore/ diff --git a/README.md b/README.md index fc07e7c..73aff45 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,21 @@ csscss: { } ``` +### Outputting analysis to a file. + +Example of using the Grunt task to output the analysis from CSSCSS to a local file. The example below will create (if necessary) `output.json` file, where it will write the output from CSSCSS. If the `outputJson` property is set to true (like in the example below) then valid JSON will be written to the file. + +```js +csscss: { + options: { + outputJson: true + }, + dist: { + 'output.json' ['css/style.css'] + } +} +``` + ## Release History ### 0.5.0 (June 4th 2013) diff --git a/gruntfile.js b/gruntfile.js index b9ed37b..69499a1 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -64,9 +64,20 @@ module.exports = function(grunt) { */ globbing: { src: ['test/example/*.css'] + }, + + /** + * Tests outputting CSSCSS findings to a file. + */ + outputToFile: { + options: { + outputJson: true + }, + files: { + 'ignore/output.json': ['test/example/style.css', 'test/example/shorthand.css'] + } } } - }); /** diff --git a/tasks/csscss.js b/tasks/csscss.js index fa0cb3a..988f9d2 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -13,11 +13,18 @@ module.exports = function(grunt) { * CSSCSS tool. */ function analyze(files) { + /** * Loops over all the files specified in the src array. */ grunt.util.async.forEachSeries(files, function(file, next) { + /** + * Stores the output that is to be written to the file.dest, if one is + * specified. + */ + var output = options.outputJson ? '{' : ''; + /** * Loops over all the matches files in the src in case there are multiple. */ @@ -33,6 +40,9 @@ module.exports = function(grunt) { * Outputs the file that is being analysed. */ grunt.log.writeln(fileToBeAnalyzed); + + output += (options.outputJson) ? '\n\t"' + fileToBeAnalyzed + '": ' : fileToBeAnalyzed + '\n'; + grunt.verbose.writeln('csscss ' + cmdArgs.join(' ')); /** @@ -50,18 +60,23 @@ module.exports = function(grunt) { }); /** - * displays the output and error streams via the parent process. + * Displays the output and error streams via the parent process. */ child.stdout.on('data', function(buf) { - var output = String(buf); - grunt.log.writeln(output); + var childOutput = String(buf); + grunt.log.writeln(childOutput); + + /** + * Substring removes the carriage return from CSSCSS. + */ + output += (options.outputJson) ? childOutput.substring(0, childOutput.length - 2) + ',' : childOutput; /** * When outputting JSON from CSSCSS an empty array will be outputted, this * should be ignored and shouldn't cause the grunt task to fail if no other * duplicates are found. */ - if (!(options.outputJson && JSON.parse(output).length === 0)) { + if (!(options.outputJson && JSON.parse(childOutput).length === 0)) { hasDuplicates = true; } }); @@ -71,9 +86,26 @@ module.exports = function(grunt) { }); }, function () { + + /** + * Removes the final comma so valid JSON is outputted. Also the end brace + * for the JSON object is included. + */ + if (options.outputJson) { + output = output.substring(0, output.length - 1); + output += '\n}'; + } + + /** + * Write the output to the destination file if one was specified. + */ + if (file.dest) { + grunt.file.write(file.dest, output); + } next(); }); }, function () { + /** * If instructed to fail when a match happens and matches found lets fail * the grunt build. @@ -213,5 +245,4 @@ module.exports = function(grunt) { analyze(this.files); }); - }; From bbeac390cea605923795ad93303620257bc237f5 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Fri, 9 Aug 2013 09:17:28 +0100 Subject: [PATCH 28/40] moved release history from README into a CHANGELOG file. --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ README.md | 32 +------------------------------- 2 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c40a496 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,31 @@ +### 0.5.0 (June 4th 2013) + +* Specifying which files CSSCSS should analyse now supports glob patterns. ([#7](https://github.com/peterkeating/grunt-csscss/issues/7)) +* Fixed typos in the documentation. ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) +* Added `bundleExec` option to run CSSCSS in the context of a bundle. ([#6](https://github.com/peterkeating/grunt-csscss/issues/6)) + +### 0.4.0 (April 21st 2013) + +* Added `ignoreSassMixins` option to ignore matches in Sass mixins. +* Added `require` option for loading Ruby file before running CSSCSS. +* Updated the `compassConfig` option to use the `--require` argument instead of the now deprecated `--compass-with-config` argument. +* Deprecated `compassConfig` option. + +### 0.3.1 (April 17th 2013) + +* Fixed bug with grunt task failing when CSSCSS outputs JSON even though duplicates weren't found. ([#3](https://github.com/peterkeating/grunt-csscss/issues/3)) +* Performance improvements by moving re-used argument construction outside the file loop. + +### 0.3.0 (April 16th 2013) + +* Added `failWhenDuplicates` option to fail Grunt task when CSSCSS finds rule sets with duplicate declarations. ([#2](https://github.com/peterkeating/grunt-csscss/issues/2)) + +### 0.2.0 (April 13th 2013) + +* Added `showParserErrors` option to output parser errors. +* Added `shorthand` option to determined whether shorthand should be parsed. +* Added `compassConfig` option to specify path to Compass config file. + +### 0.1.0 (April 12th 2013) + +* Initial release supporting all options for CSSCSS v1.0.0. diff --git a/README.md b/README.md index 73aff45..d1956dc 100644 --- a/README.md +++ b/README.md @@ -226,37 +226,7 @@ csscss: { ## Release History -### 0.5.0 (June 4th 2013) - -* Specifying which files CSSCSS should analyse now supports glob patterns. ([#7](https://github.com/peterkeating/grunt-csscss/issues/7)) -* Fixed typos in the documentation. ([#5](https://github.com/peterkeating/grunt-csscss/issues/5)) -* Added `bundleExec` option to run CSSCSS in the context of a bundle. ([#6](https://github.com/peterkeating/grunt-csscss/issues/6)) - -### 0.4.0 (April 21st 2013) - -* Added `ignoreSassMixins` option to ignore matches in Sass mixins. -* Added `require` option for loading Ruby file before running CSSCSS. -* Updated the `compassConfig` option to use the `--require` argument instead of the now deprecated `--compass-with-config` argument. -* Deprecated `compassConfig` option. - -### 0.3.1 (April 17th 2013) - -* Fixed bug with grunt task failing when CSSCSS outputs JSON even though duplicates weren't found. ([#3](https://github.com/peterkeating/grunt-csscss/issues/3)) -* Performance improvements by moving re-used argument construction outside the file loop. - -### 0.3.0 (April 16th 2013) - -* Added `failWhenDuplicates` option to fail Grunt task when CSSCSS finds rule sets with duplicate declarations. ([#2](https://github.com/peterkeating/grunt-csscss/issues/2)) - -### 0.2.0 (April 13th 2013) - -* Added `showParserErrors` option to output parser errors. -* Added `shorthand` option to determined whether shorthand should be parsed. -* Added `compassConfig` option to specify path to Compass config file. - -### 0.1.0 (April 12th 2013) - -* Initial release supporting all options for CSSCSS v1.0.0. +See [CHANGELOG](https://github.com/peterkeating/grunt-csscss/blob/master/CHANGELOG.md). ## Credits From b08cc8f08aafe0ba215bde88f858115885bbd075 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Fri, 9 Aug 2013 09:20:12 +0100 Subject: [PATCH 29/40] removed compassConfig option. --- README.md | 10 ---------- tasks/csscss.js | 14 -------------- 2 files changed, 24 deletions(-) diff --git a/README.md b/README.md index d1956dc..67a8b09 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,6 @@ Enables Compass extensions when parsing Sass. *[Compass](http://compass-style.org/) must be installed in order to use this option.* -### compassConfig - DEPRECATED - -Type: `String` - -Enables Compass extension and specifies path to a config file. - -**This option is deprecated, the require option should be used.** - -*[Compass](http://compass-style.org/) must be installed in order to use this option.* - ### failWhenDuplicates Type: `Boolean` diff --git a/tasks/csscss.js b/tasks/csscss.js index 988f9d2..cfb49e6 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -167,20 +167,6 @@ module.exports = function(grunt) { args.push('--compass'); } - /** - * Enables Compass extensions when parsing Sass files and specifies the path - * to the config file. - * The compassConfig option is deprecated and will be removed in a future release. - * The require option should be used instead. - */ - if (options.compassConfig && !options.require) { - args.push('--compass'); - args.push('--require'); - args.push(options.compassConfig); - - grunt.log.writeln('WARNING: compassConfig is DEPRECATED, please use the "require" option.'); - } - /** * Enables Compass extensions when parsing Sass files and specifies the path * to the config file. From 3db67cba28028699c665c691f9621ae69cdce12c Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sat, 17 Aug 2013 10:34:08 +0100 Subject: [PATCH 30/40] updated to v0.6.0. --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c40a496..eb30a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 0.6.0 (August 17th 2013) + +* Removed `compassConfig` option. +* Refactored task to use [`this.files` instead of `this.data`](http://dontkry.com/posts/code/2013-04-24-use-this-files.html). +* Added ability to write output from CSSCSS to a file. + ### 0.5.0 (June 4th 2013) * Specifying which files CSSCSS should analyse now supports glob patterns. ([#7](https://github.com/peterkeating/grunt-csscss/issues/7)) diff --git a/package.json b/package.json index b3707c2..5073367 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.5.0", + "version": "0.6.0", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 2f919dae1f19f2bc6b3d75c96c8d5361e9eca1a7 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Sat, 17 Aug 2013 10:36:44 +0100 Subject: [PATCH 31/40] added link to issue for new feature in CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb30a45..4c2df84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ * Removed `compassConfig` option. * Refactored task to use [`this.files` instead of `this.data`](http://dontkry.com/posts/code/2013-04-24-use-this-files.html). -* Added ability to write output from CSSCSS to a file. +* Added ability to write output from CSSCSS to a file. ([#8](https://github.com/peterkeating/grunt-csscss/issues/8)) ### 0.5.0 (June 4th 2013) From adc0ad2d0a04a8ecb7f61864c50d09d5f22b2f17 Mon Sep 17 00:00:00 2001 From: Josh Matz Date: Thu, 22 Aug 2013 12:41:36 -0500 Subject: [PATCH 32/40] Added colon to the file output example Just added a colon for those trying to use the example code :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 67a8b09..f24c2ed 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ csscss: { outputJson: true }, dist: { - 'output.json' ['css/style.css'] + 'output.json': ['css/style.css'] } } ``` From bf91f14ff56ef35b466efa28427071c727827f3f Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Fri, 13 Sep 2013 17:18:07 +0100 Subject: [PATCH 33/40] updated CHANGELOG with 0.6.1 changes. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c2df84..2f39844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 0.6.1 (September 13th 2013) + +* Fixed typo in documentation example courtesy of [joshmatz](https://github.com/joshmatz). ([#9](https://github.com/peterkeating/grunt-csscss/pull/9)) + ### 0.6.0 (August 17th 2013) * Removed `compassConfig` option. From 9d78790e7f685a9c81c8481cbb57bac37717b7cb Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Fri, 13 Sep 2013 17:18:26 +0100 Subject: [PATCH 34/40] updated to v0.6.1. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5073367..c94d45a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.6.0", + "version": "0.6.1", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 2a4c43b55d2aaccd49544128d4c53dc9aaea1c11 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 20 Feb 2014 23:36:05 +0000 Subject: [PATCH 35/40] updated to grunt 0.4.2. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c94d45a..9a1ed09 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test": "grunt" }, "devDependencies": { - "grunt": "~0.4.1", + "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.4.3" }, "keywords": [ From 7bb86438a2bd47e66a9deb1f4b39e58f54b93689 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 20 Feb 2014 23:36:50 +0000 Subject: [PATCH 36/40] fixed bug causing task to fail when processing extremely large CSS files. --- tasks/csscss.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tasks/csscss.js b/tasks/csscss.js index cfb49e6..2126400 100644 --- a/tasks/csscss.js +++ b/tasks/csscss.js @@ -34,7 +34,12 @@ module.exports = function(grunt) { * adds the file path as the final argument, this goes into a new array so * the file doesn't get used in the next iteration. */ - var cmdArgs = args.concat([fileToBeAnalyzed]); + var cmdArgs = args.concat([fileToBeAnalyzed]), + + /** + * Stores the output from CSSCSS. + */ + childOutput = ''; /** * Outputs the file that is being analysed. @@ -56,14 +61,6 @@ module.exports = function(grunt) { return grunt.warn('Ruby and csscss have to be installed and in your PATH for this task to run.'); } - innerNext(error); - }); - - /** - * Displays the output and error streams via the parent process. - */ - child.stdout.on('data', function(buf) { - var childOutput = String(buf); grunt.log.writeln(childOutput); /** @@ -79,6 +76,15 @@ module.exports = function(grunt) { if (!(options.outputJson && JSON.parse(childOutput).length === 0)) { hasDuplicates = true; } + + innerNext(error); + }); + + /** + * Displays the output and error streams via the parent process. + */ + child.stdout.on('data', function(buf) { + childOutput += String(buf); }); child.stderr.on('data', function(buf) { From 708372cdf855cbb52337c7fad74132ba8b034af2 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 20 Feb 2014 23:38:03 +0000 Subject: [PATCH 37/40] updated example of outputting analysis to a file. --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f24c2ed..587109a 100644 --- a/README.md +++ b/README.md @@ -205,11 +205,13 @@ Example of using the Grunt task to output the analysis from CSSCSS to a local fi ```js csscss: { - options: { - outputJson: true - }, dist: { - 'output.json': ['css/style.css'] + options: { + outputJson: true + }, + files: { + 'output.json': ['css/style.css'] + } } } ``` From 8c7548c3f1fac520f533f44d577e15a7210fc2a7 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 20 Feb 2014 23:38:33 +0000 Subject: [PATCH 38/40] updated package to 0.6.2. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a1ed09..cba9f46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grunt-csscss", - "version": "0.6.1", + "version": "0.6.2", "description": "Grunt task that executes CSSCSS.", "homepage": "https://github.com/peterkeating/grunt-csscss", "author": { From 8ce48590a52b4d819df3d6144de592bee7835a93 Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Thu, 20 Feb 2014 23:40:30 +0000 Subject: [PATCH 39/40] updated the change log with updates. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f39844..f267faf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 0.6.2 (Not yet released) + +* Updated grunt dependency to 0.4.2. +* Fixed example in README of outputting analysis to a file. +* Fixed issue causing task to crash when processing files with extreme amounts of duplication. + ### 0.6.1 (September 13th 2013) * Fixed typo in documentation example courtesy of [joshmatz](https://github.com/joshmatz). ([#9](https://github.com/peterkeating/grunt-csscss/pull/9)) From 9801b86fec7dcc8656d364bf74872b115f2bfa8f Mon Sep 17 00:00:00 2001 From: Peter Keating Date: Mon, 28 Apr 2014 22:13:04 +0100 Subject: [PATCH 40/40] released v0.6.2. --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f267faf..a5a7b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ -### 0.6.2 (Not yet released) +### 0.6.2 (28th April 2014) * Updated grunt dependency to 0.4.2. * Fixed example in README of outputting analysis to a file. -* Fixed issue causing task to crash when processing files with extreme amounts of duplication. +* Fixed issue causing task to crash when processing files with large amounts of duplication. ### 0.6.1 (September 13th 2013)