Skip to content
Browse files

Followup to making task grunt 0.4 compatible

Also improve code style
  • Loading branch information...
1 parent 5151fe2 commit 8dca64b5261be5719c8a88d10add77250b6ce67f @sindresorhus committed Jan 6, 2013
Showing with 39 additions and 56 deletions.
  1. +11 −30 Gruntfile.js
  2. +3 −3 package.json
  3. +3 −0 readme.md
  4. +22 −23 tasks/recess.js
View
41 Gruntfile.js
@@ -1,6 +1,5 @@
-module.exports = function( grunt ) {
- 'use strict';
-
+'use strict';
+module.exports = function (grunt) {
grunt.initConfig({
recess: {
pass: {
@@ -15,38 +14,20 @@ module.exports = function( grunt ) {
]
}
},
- watch: {
- files: '<config:lint.files>',
- tasks: 'default'
- },
jshint: {
- lint: [
- 'grunt.js',
- 'tests/**/*.js'
- ],
options: {
- es5: true,
- esnext: true,
- bitwise: true,
- curly: true,
- eqeqeq: true,
- latedef: true,
- newcap: true,
- noarg: true,
- noempty: true,
- regexp: true,
- undef: true,
- strict: true,
- trailing: true,
- smarttabs: true,
- node: true
- }
+ jshintrc: '.jshintrc'
+ },
+ all: [
+ 'Gruntfile.js',
+ 'tasks/*.js',
+ 'tests/*.js'
+ ]
}
});
grunt.loadTasks('tasks');
- grunt.loadNpmTasks('grunt-contrib-jshint');
-
- grunt.registerTask( 'default', ['jshint', 'recess:pass', 'recess:fail'] );
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.registerTask('default', ['jshint', 'recess:pass', 'recess:fail']);
};
View
6 package.json
@@ -18,18 +18,18 @@
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
- "main": "grunt.js",
+ "main": "Gruntfile.js",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/grunt-recess.git"
},
"dependencies": {
"recess": "~1.1.6",
- "grunt-lib-legacyhelpers": "~0.1.x"
+ "grunt-lib-legacyhelpers": "~0.1.0"
},
"devDependencies": {
"grunt": "~0.4.0",
- "grunt-contrib-jshint": "~0.1.x"
+ "grunt-contrib-jshint": "~0.1.0"
},
"engines": {
"node": ">=0.8.0"
View
3 readme.md
@@ -9,6 +9,8 @@
## Getting Started
+**Requires grunt 0.4**
+
Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-recess`
Then add this line to your project's `grunt.js` gruntfile:
@@ -89,6 +91,7 @@ noUniversalSelectors: true // Doesn't complain about using the universal * selec
prefixWhitespace: true // Adds whitespace prefix to line up vender prefixed properties
strictPropertyOrder: true // Complains if not strict property order
stripColors: false // Strip colors from the Terminal output
+// ^ Deprecated. Instead pass `--no-color` to grunt
zeroUnits: true // Doesn't complain if you add units to values of 0
```
View
45 tasks/recess.js
@@ -1,24 +1,22 @@
-
-module.exports = function( grunt ) {
- 'use strict';
-
- grunt.registerMultiTask('recess', 'Lint and minify CSS and LESS', function() {
+'use strict';
+module.exports = function (grunt) {
+ grunt.registerMultiTask('recess', 'Lint and minify CSS and LESS', function () {
var recess = require('recess');
- var helpers = require('grunt-lib-legacyhelpers').init(grunt);
+ var helpers = require('grunt-lib-legacyhelpers').init(grunt);
var lf = grunt.util.linefeed;
var cb = this.async();
- var files = grunt.file.expandFiles( this.file.src );
+ var files = this.file.src;
var dest = this.file.dest;
var options = this.data.options || {};
var compress = options.compress;
var separator = compress ? '' : lf + lf;
- if ( !files.length ) {
+ if (!files.length) {
grunt.log.writeln('No existing files in this target.');
return cb();
}
- recess( files, options, function( err, data ) {
+ recess(files, options, function (err, data) {
var min = [];
var max = [];
@@ -28,28 +26,29 @@ module.exports = function( grunt ) {
//
// .reverse() the array because of bug:
// https://github.com/twitter/recess/issues/42
- data = Array.isArray( data ) ? data.reverse() : [ data ];
+ data = Array.isArray(data) ? data.reverse() : [data];
- data.forEach(function( item ) {
- if ( item.options.compile ) {
- min.push( item.output );
- max.push( item.data );
+ data.forEach(function (item) {
+ if (item.options.compile) {
+ min.push(item.output);
+ max.push(item.data);
// Extract status and check
- } else if ( item.output[1] && item.output[1].indexOf('Perfect!') !== -1 ) {
- grunt.log.writeln( item.output.join( lf ) );
+ } else if (item.output[1] && item.output[1].indexOf('Perfect!') !== -1) {
+ grunt.log.writeln(item.output.join(lf));
} else {
- grunt.fail.warn( item.output.join( lf ) );
+ grunt.fail.warn(item.output.join(lf));
}
});
- if ( min.length ) {
- if ( dest ) {
+ if (min.length) {
+ if (dest) {
// Concat files
- grunt.file.write( dest, min.join( separator ) );
- grunt.log.writeln( 'File "' + dest + '" created.' );
+ grunt.file.write(dest, min.join(separator));
+ grunt.log.writeln('File "' + dest + '" created.');
- if ( compress ) {
- helpers.min_max_info(min.join( separator ), max.join( separator ) );
+ if (compress) {
+ /*jshint camelcase:false */
+ helpers.min_max_info(min.join(separator), max.join(separator));
}
} else {
grunt.fail.fatal('No destination specified. Required when options.compile is enabled.');

0 comments on commit 8dca64b

Please sign in to comment.
Something went wrong with that request. Please try again.