Skip to content

Commit

Permalink
Init project
Browse files Browse the repository at this point in the history
  • Loading branch information
sexnothing committed Jul 12, 2013
1 parent 6962e8c commit ce8fd87
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
41 changes: 41 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = function(grunt) {
"use strict";
// Project configuration.
grunt.initConfig({
// Configuration to be run
cssbeautifier: {
files: ['test/*.css'],
options: {
indent: ' ',
openbrace: 'end-of-line',
autosemicolon: true
}
},
jshint: {
files: ['Gruntfile.js', 'tasks/**/*.js', 'test/**/*.js'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
es5: true
}
}
});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');

// By default, beautifiy, lint and run all tests.
grunt.registerTask('default', ['cssbeautifier', 'jshint']);
};
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "grunt-cssbeautifier",
"description": "cssbeautify.com for grunt",
"version": "0.1.9",
"homepage": "https://github.com/sexnothing/grunt-cssbeautifier",
"author": {
"name": "liaowei",
"email": "sexnothing@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/sexnothing/grunt-cssbeautifier.git"
},
"bugs": {
"url": "https://github.com/sexnothing/grunt-cssbeautifier/issues"
},
"licenses": [
{
"type": "MIT"
}
],
"engines": {
"node": ">=0.8"
},
"dependencies": {
"grunt": "~0.4.1",
"cssbeautify": "latest"
},
"devDependencies": {
"grunt-contrib-jshint": "latest"
},
"keywords": [
"gruntplugin",
"beautify",
"beautifier",
"cssbeautifier",
"code-quality"
],
"readmeFilename": "README.md"
}
32 changes: 32 additions & 0 deletions tasks/cssbeautifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = function(grunt) {
"use strict";
// Please see the grunt documentation for more information regarding task.
grunt.task.registerMultiTask('cssbeautifier', 'cssbeautify.com for grunt', function() {
var beautify = require('cssbeautify');
var params = this.options();
var fileCount = 0;
var changedFileCount = 0;

if (this.filesSrc) {
grunt.verbose.writeln('Beautifing using filesSrc with ' + this.filesSrc.length.toString().cyan + ' files...');
this.filesSrc.forEach(function(src) {
if (grunt.file.isDir(src)) {
return;
}

var original = grunt.file.read(src);
grunt.verbose.write('Beautifing ' + src.cyan + '...');
var result = beautify(original, params);
result += '\n';
grunt.verbose.ok();
if (original !== result) {
grunt.file.write(src, result);
changedFileCount++;
}
fileCount++;
});
}
grunt.log.write('Beautified ' + fileCount.toString().cyan + ' files, changed ' + changedFileCount.toString().cyan + ' files...');
grunt.log.ok();
});
};
5 changes: 5 additions & 0 deletions test/ugly.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
color: #eeeeee;
font-size: 12
}

0 comments on commit ce8fd87

Please sign in to comment.