Skip to content

Commit

Permalink
Updating task to conform to 0.4 API.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Oct 18, 2012
1 parent 46fa8e1 commit ea7551c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
29 changes: 12 additions & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,25 @@
* Licensed under the MIT license.
*/

module.exports = function(grunt) {
"use strict";
'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<config:nodeunit.tests>',
'<%= nodeunit.tests %>'
],
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,
jshintrc: '.jshintrc'
},
},

// Configuration to be run (and then tested).
clean: {
test: ['tmp'],
short: ['tmp/sample_short'],
long: {
src: ['tmp/sample_long'],
Expand All @@ -50,6 +40,11 @@
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

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

// Setup a test helper to create some folders to clean.
grunt.registerTask('copy', 'Copy fixtures to a temp location.', function() {
grunt.file.copy('test/fixtures/sample_long/long.txt', 'tmp/sample_long/long.txt');
Expand All @@ -61,5 +56,5 @@
grunt.registerTask('test', ['copy', 'clean', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
};
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"test": "grunt test"
},
"dependencies": {
"rimraf": "~2.0.2",
"grunt-contrib-lib": "~0.3.0"
},
"devDependencies": {
"grunt": "devel"
"grunt-contrib-jshint": "0.1.0",
"grunt-contrib-nodeunit": "0.1.0",
"grunt-contrib-internal": "*",
"grunt": "~0.4.0a"
},
"keywords": [
"gruntplugin"
Expand Down
17 changes: 9 additions & 8 deletions tasks/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
* Licensed under the MIT license.
*/

'use strict';

module.exports = function(grunt) {
'use strict';

grunt.registerMultiTask('clean', 'Clean files and folders.', function() {

var helpers = require('grunt-contrib-lib').init(grunt);
var options = helpers.options(this);
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options();

grunt.verbose.writeflags(options, 'Options');
var paths = grunt.file.expand(this.files[0].src);

paths.forEach(function(path) {
grunt.log.write('Cleaning "' + path + '"...');
// Clean specified files / dirs.
var files = grunt.file.expand(grunt.util._.pluck(this.files, 'src'));
files.forEach(function(filepath) {
grunt.log.write('Cleaning "' + filepath + '"...');
try {
require('rimraf').sync(path);
grunt.file.delete(filepath);
grunt.log.ok();
} catch (e) {
grunt.log.error();
Expand Down

0 comments on commit ea7551c

Please sign in to comment.