grunt-contrib-clean
Advanced tools
Comparing version 0.7.0 to 1.0.0
{ | ||
"name": "grunt-contrib-clean", | ||
"description": "Clean files and folders", | ||
"version": "0.7.0", | ||
"version": "1.0.0", | ||
"author": { | ||
@@ -12,4 +12,5 @@ "name": "Grunt Team", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">= 0.10.0" | ||
}, | ||
"main": "tasks/clean.js", | ||
"scripts": { | ||
@@ -19,13 +20,15 @@ "test": "grunt test" | ||
"dependencies": { | ||
"rimraf": "^2.2.1" | ||
"async": "^1.5.2", | ||
"rimraf": "^2.5.1" | ||
}, | ||
"devDependencies": { | ||
"dir-compare": "0.0.2", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-internal": "^0.4.10", | ||
"grunt-contrib-jshint": "^0.11.0", | ||
"grunt-contrib-jshint": "^0.12.0", | ||
"grunt-contrib-nodeunit": "^0.4.1" | ||
}, | ||
"peerDependencies": { | ||
"grunt": ">=0.4.0" | ||
"grunt": ">= 0.4.5" | ||
}, | ||
@@ -32,0 +35,0 @@ "keywords": [ |
@@ -8,3 +8,2 @@ # grunt-contrib-clean v0.7.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-clean.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-clean) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/li28411ceq3n833d/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-clean/branch/master) | ||
## Getting Started | ||
This plugin requires Grunt `>=0.4.0` | ||
@@ -45,4 +44,7 @@ If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: | ||
Will log messages of what would happen if the task was ran but doesn't actually delete the files. | ||
Will not actually delete any files or directories. | ||
If the task is run with the `--verbose` flag, the task will log messages of what files would have be deleted. | ||
_Note: As this task property contains a hyphen, you will need to surround it with quotes._ | ||
### Usage Examples | ||
@@ -77,2 +79,27 @@ | ||
"Compact" and "Files Array" formats support a few [additional properties](http://gruntjs.com/configuring-tasks#files) | ||
which help you deal with hidden files, process dynamic mappings and so on. | ||
#### Globbing Patterns | ||
Although documented [in the Grunt Docs](http://gruntjs.com/configuring-tasks#globbing-patterns), here are some globbing pattern examples to achieve some common tasks: | ||
```js | ||
clean: { | ||
folder: ['path/to/dir/'], | ||
folder_v2: ['path/to/dir/**'], | ||
contents: ['path/to/dir/*'], | ||
subfolders: ['path/to/dir/*/'], | ||
css: ['path/to/dir/*.css'], | ||
all_css: ['path/to/dir/**/*.css'] | ||
} | ||
``` | ||
* __`folder`:__ Deletes the `dir/` folder | ||
* __`folder_v2`:__ Deletes the `dir/` folder | ||
* __`contents`:__ Keeps the `dir/` folder, but deletes the contents | ||
* __`subfolders`:__ Keeps the files inside the `dir/` folder, but deletes all subfolders | ||
* __`css`:__ Deletes all `*.css` files inside the `dir/` folder, excluding subfolders | ||
* __`all_css`:__ Deletes all `*.css` files inside the `dir/` folder and its subfolders | ||
##### Skipping Files | ||
@@ -87,8 +114,39 @@ | ||
"Compact" and "Files Array" formats support a few [additional properties](http://gruntjs.com/configuring-tasks#files) | ||
which help you deal with hidden files, process dynamic mappings and so on. | ||
###### Options | ||
Options can be specified for all `clean` tasks and for each `clean:target`. | ||
####### All tasks | ||
```js | ||
// Prevents all targets from deleting any files | ||
clean: { | ||
options: { | ||
'no-write': true | ||
}, | ||
build: ['dev/build'], | ||
release: ['dist'] | ||
} | ||
``` | ||
####### Per-target | ||
```js | ||
// Will delete files for `build` target | ||
// Will NOT delete files for `release` target | ||
clean: { | ||
build: ['dev/build'], | ||
release: { | ||
options: { | ||
'no-write': true | ||
}, | ||
src: ['dist'] | ||
} | ||
} | ||
``` | ||
## Release History | ||
* 2016-02-15 v1.0.0 Drop support for Node.js v0.8 Grunt peer dependency tagged `>= 0.4.5` Dependency updates | ||
* 2015-11-13 v0.7.0 Dependency updates | ||
@@ -109,2 +167,2 @@ * 2014-07-27 v0.6.0 Less verbose output. README updates. | ||
*This file was generated on Fri Nov 13 2015 14:04:25.* | ||
*This file was generated on Mon Feb 15 2016 13:42:25.* |
@@ -5,3 +5,3 @@ /* | ||
* | ||
* Copyright (c) 2015 Tim Branyen, contributors | ||
* Copyright (c) 2016 Tim Branyen, contributors | ||
* Licensed under the MIT license. | ||
@@ -12,2 +12,3 @@ */ | ||
var async = require('async'); | ||
var rimraf = require('rimraf'); | ||
@@ -17,5 +18,5 @@ | ||
function clean(filepath, options) { | ||
function clean(filepath, options, done) { | ||
if (!grunt.file.exists(filepath)) { | ||
return false; | ||
return done(); | ||
} | ||
@@ -28,20 +29,22 @@ | ||
grunt.fail.warn('Cannot delete the current working directory.'); | ||
return false; | ||
return done(); | ||
} else if (!grunt.file.isPathInCwd(filepath)) { | ||
grunt.verbose.error(); | ||
grunt.fail.warn('Cannot delete files outside the current working directory.'); | ||
return false; | ||
return done(); | ||
} | ||
} | ||
try { | ||
// Actually delete. Or not. | ||
if (!options['no-write']) { | ||
rimraf.sync(filepath); | ||
grunt.verbose.writeln((options['no-write'] ? 'Not actually cleaning ' : 'Cleaning ') + filepath + '...'); | ||
// Actually delete. Or not. | ||
if (options['no-write']) { | ||
return done(); | ||
} | ||
rimraf(filepath, function (err) { | ||
if (err) { | ||
grunt.log.error(); | ||
grunt.fail.warn('Unable to delete "' + filepath + '" file (' + err.message + ').', err); | ||
} | ||
grunt.verbose.writeln((options['no-write'] ? 'Not actually cleaning ' : 'Cleaning ') + filepath + '...'); | ||
} catch (e) { | ||
grunt.log.error(); | ||
grunt.fail.warn('Unable to delete "' + filepath + '" file (' + e.message + ').', e); | ||
} | ||
done(); | ||
}); | ||
} | ||
@@ -56,9 +59,14 @@ | ||
var done = this.async(); | ||
// Clean specified files / dirs. | ||
this.filesSrc.forEach(function(filepath) { | ||
clean(filepath, options); | ||
var files = this.filesSrc; | ||
async.eachSeries(files, function (filepath, cb) { | ||
clean(filepath, options, cb); | ||
}, function (err) { | ||
grunt.log.ok(files.length + ' ' + grunt.util.pluralize(files.length, 'path/paths') + ' cleaned.'); | ||
done(err); | ||
}); | ||
grunt.log.ok(this.filesSrc.length + ' ' + grunt.util.pluralize(this.filesSrc.length, 'path/paths') + ' cleaned.'); | ||
}); | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9737
57
1
164
3
6
+ Addedasync@^1.5.2
+ Addedasync@1.5.2(transitive)
Updatedrimraf@^2.5.1