[Pkg-javascript-commits] [node-grunt-contrib-clean] 01/04: Import Upstream version 1.0.0
Sruthi Chandran
srud-guest at moszumanska.debian.org
Sun Nov 13 10:53:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
srud-guest pushed a commit to branch master
in repository node-grunt-contrib-clean.
commit f6bffc7c0655cdd125f9ff6eaa191f658f0f9270
Author: Sruthi <srud at disroot.org>
Date: Sun Nov 13 16:04:28 2016 +0530
Import Upstream version 1.0.0
---
.gitattributes | 1 +
.gitignore | 3 +
.jshintrc | 14 +++
.travis.yml | 14 +++
AUTHORS | 6 ++
CHANGELOG | 52 +++++++++++
CONTRIBUTING.md | 1 +
Gruntfile.js | 76 ++++++++++++++++
LICENSE-MIT | 22 +++++
README.md | 163 +++++++++++++++++++++++++++++++++++
appveyor.yml | 32 +++++++
docs/clean-examples.md | 95 ++++++++++++++++++++
docs/clean-options.md | 16 ++++
docs/clean-overview.md | 3 +
docs/overview.md | 1 +
package.json | 48 +++++++++++
tasks/clean.js | 67 ++++++++++++++
test/clean_test.js | 33 +++++++
test/expected/end_01/1.txt | 0
test/expected/end_02/2/1.txt | 0
test/fixtures/sample_long/long.txt | 1 +
test/fixtures/sample_short/short.txt | 1 +
test/fixtures/start/1.txt | 0
test/fixtures/start/2.txt | 0
test/fixtures/start/2/1.txt | 0
25 files changed, 649 insertions(+)
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5cb6bfd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+tmp
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..507f912
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,14 @@
+{
+ "boss": true,
+ "curly": true,
+ "eqeqeq": true,
+ "eqnull": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "node": true,
+ "sub": true,
+ "undef": true,
+ "unused": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..578bc95
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,14 @@
+sudo: false
+language: node_js
+node_js:
+ - "0.10"
+ - "0.12"
+ - "4"
+ - "5"
+ - "iojs"
+before_install:
+ - npm install -g npm
+before_script:
+ - npm install -g grunt-cli
+matrix:
+ fast_finish: true
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..393d814
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,6 @@
+Tim Branyen (http://tbranyen.com/)
+Tyler Kellen (http://goingslowly.com/)
+Chris Talkington (http://christalkington.com/)
+Sebastian Golasch (http://www.asciidisco.com/)
+Vlad Filippov (http://vf.io)
+"Cowboy" Ben Alman (http://benalman.com/)
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
index 0000000..0f55e54
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,52 @@
+v1.0.0:
+ date: 2016-02-15
+ changes:
+ - Drop support for Node.js v0.8
+ - Grunt peer dependency tagged `>= 0.4.5`
+ - Dependency updates
+v0.7.0:
+ date: 2015-11-13
+ changes:
+ - Dependency updates
+v0.6.0:
+ date: 2014-07-27
+ changes:
+ - Less verbose output.
+ - README updates.
+v0.5.0:
+ date: 2013-07-15
+ changes:
+ - Use rimraf directly, version 2.2.1 to fix issue on Windows.
+ - Add no-write option to mimic grunt.file.delete behavior.
+v0.4.1:
+ date: 2013-04-16
+ changes:
+ - Check if file exists to avoid trying to delete a non-existent file.
+v0.4.0:
+ date: 2013-02-15
+ changes:
+ - First official release for Grunt 0.4.0.
+v0.4.0rc6:
+ date: 2013-01-18
+ changes:
+ - Updating grunt/gruntplugin dependencies to rc6.
+ - Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
+v0.4.0rc5:
+ date: 2013-01-09
+ changes:
+ - Updating to work with grunt v0.4.0rc5.
+ - Switching to this.filesSrc api.
+v0.4.0a:
+ date: 2012-12-07
+ changes:
+ - Conversion to grunt v0.4 conventions.
+ - Remove node v0.6 and grunt v0.3 support.
+ - Add force option to bypass CWD check.
+v0.3.0:
+ date: 2012-09-23
+ changes:
+ - Options no longer accepted from global config key.
+v0.2.0:
+ date: 2012-09-10
+ changes:
+ - Refactored from grunt-contrib into individual repo.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..5d08cc3
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1 @@
+Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project.
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..e448842
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,76 @@
+/*
+ * grunt-contrib-clean
+ * http://gruntjs.com/
+ *
+ * Copyright (c) 2016 Tim Branyen, contributors
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'tasks/*.js',
+ '<%= nodeunit.tests %>'
+ ],
+ options: {
+ jshintrc: '.jshintrc'
+ }
+ },
+
+ // Configuration to be run (and then tested).
+ clean: {
+ shortPathTest: ['tmp/sample_short'],
+ longPathTest: {
+ src: ['tmp/sample_long']
+ },
+ exclude: ['tmp/end_01/**/*', '!tmp/end_01/1.txt'],
+ excludeSub: ['tmp/end_02/**/*.*', '!tmp/end_02/2/**/*']
+ },
+
+ // Unit tests.
+ nodeunit: {
+ tests: ['test/*_test.js']
+ }
+ });
+
+ // 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');
+ grunt.file.copy('test/fixtures/sample_short/short.txt', 'tmp/sample_short/short.txt');
+
+ var cwd = 'test/fixtures/start';
+ grunt.file.expand({
+ cwd: cwd
+ }, '**/*.*')
+ .forEach(function (file) {
+ var ecwd = 'test/expected';
+ grunt.file.expand({
+ cwd: ecwd
+ }, '*')
+ .forEach(function (dir) {
+ grunt.file.copy(cwd + '/' + file, 'tmp/' + dir + '/' + file);
+ });
+ });
+ });
+
+ // Whenever the 'test' task is run, first create some files to be cleaned,
+ // then run this plugin's task(s), then test the result.
+ grunt.registerTask('test', ['jshint', 'copy', 'clean', 'nodeunit']);
+
+ // By default, lint and run all tests.
+ grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
+};
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..499a8e6
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2016 Tim Branyen, contributors
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f93ec03
--- /dev/null
+++ b/README.md
@@ -0,0 +1,163 @@
+# 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)
+
+> Clean files and folders
+
+
+
+## Getting Started
+
+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:
+
+```shell
+npm install grunt-contrib-clean --save-dev
+```
+
+Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
+
+```js
+grunt.loadNpmTasks('grunt-contrib-clean');
+```
+
+*This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-clean/tree/grunt-0.3-stable).*
+
+
+
+## Clean task
+_Run this task with the `grunt clean` command._
+
+Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.
+
+*Due to the destructive nature of this task, always be cautious of the paths you clean.*
+### Options
+
+#### force
+Type: `Boolean`
+Default: `false`
+
+This overrides this task from blocking deletion of folders outside current working dir (CWD). Use with caution.
+
+#### no-write
+Type: `Boolean`
+Default: `false`
+
+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
+
+There are three formats you can use to run this task.
+
+#### Short
+
+```js
+clean: ["path/to/dir/one", "path/to/dir/two"]
+```
+
+#### Medium (specific targets with global options)
+
+```js
+clean: {
+ build: ["path/to/dir/one", "path/to/dir/two"],
+ release: ["path/to/another/dir/one", "path/to/another/dir/two"]
+},
+```
+
+#### Long (specific targets with per target options)
+
+```js
+clean: {
+ build: {
+ src: ["path/to/dir/one", "path/to/dir/two"]
+ }
+}
+```
+
+"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
+
+```js
+// Deletes all .js files, but skips min.js files
+clean: {
+ js: ["path/to/dir/*.js", "!path/to/dir/*.min.js"]
+}
+```
+
+###### 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
+ * 2014-07-27 v0.6.0 Less verbose output. README updates.
+ * 2013-07-15 v0.5.0 Use rimraf directly, version 2.2.1 to fix issue on Windows. Add no-write option to mimic grunt.file.delete behavior.
+ * 2013-04-16 v0.4.1 Check if file exists to avoid trying to delete a non-existent file.
+ * 2013-02-15 v0.4.0 First official release for Grunt 0.4.0.
+ * 2013-01-18 v0.4.0rc6 Updating grunt/gruntplugin dependencies to rc6. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
+ * 2013-01-09 v0.4.0rc5 Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api.
+ * 2012-12-07 v0.4.0a Conversion to grunt v0.4 conventions. Remove node v0.6 and grunt v0.3 support. Add force option to bypass CWD check.
+ * 2012-09-23 v0.3.0 Options no longer accepted from global config key.
+ * 2012-09-10 v0.2.0 Refactored from grunt-contrib into individual repo.
+
+---
+
+Task submitted by [Tim Branyen](http://tbranyen.com/)
+
+*This file was generated on Mon Feb 15 2016 13:42:25.*
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..92ffcda
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,32 @@
+# Fix line endings on Windows
+init:
+ - git config --global core.autocrlf true
+# What combinations to test
+environment:
+ matrix:
+ - nodejs_version: "0.10"
+ - nodejs_version: "0.12"
+ - nodejs_version: "4"
+ - nodejs_version: "5"
+platform:
+ - x86
+ - x64
+install:
+ - ps: Install-Product node $env:nodejs_version
+ - npm install -g npm
+ - npm install -g grunt-cli
+ - npm install
+test_script:
+ # Output useful info for debugging.
+ - node --version && npm --version
+ # We test multiple Windows shells because of prior stdout buffering issues
+ # filed against Grunt. https://github.com/joyent/node/issues/3584
+ - ps: "npm test # PowerShell" # Pass comment to PS for easier debugging
+ - cmd: npm test
+build: off
+matrix:
+ fast_finish: true
+cache:
+ - C:\Users\appveyor\AppData\Roaming\npm\node_modules -> package.json # global npm modules
+ - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache
+ - node_modules -> package.json # local npm modules
diff --git a/docs/clean-examples.md b/docs/clean-examples.md
new file mode 100644
index 0000000..2e55076
--- /dev/null
+++ b/docs/clean-examples.md
@@ -0,0 +1,95 @@
+# Usage Examples
+
+There are three formats you can use to run this task.
+
+## Short
+
+```js
+clean: ["path/to/dir/one", "path/to/dir/two"]
+```
+
+## Medium (specific targets with global options)
+
+```js
+clean: {
+ build: ["path/to/dir/one", "path/to/dir/two"],
+ release: ["path/to/another/dir/one", "path/to/another/dir/two"]
+},
+```
+
+## Long (specific targets with per target options)
+
+```js
+clean: {
+ build: {
+ src: ["path/to/dir/one", "path/to/dir/two"]
+ }
+}
+```
+
+"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
+
+```js
+// Deletes all .js files, but skips min.js files
+clean: {
+ js: ["path/to/dir/*.js", "!path/to/dir/*.min.js"]
+}
+```
+
+#### 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']
+ }
+}
+```
diff --git a/docs/clean-options.md b/docs/clean-options.md
new file mode 100644
index 0000000..77751bf
--- /dev/null
+++ b/docs/clean-options.md
@@ -0,0 +1,16 @@
+# Options
+
+## force
+Type: `Boolean`
+Default: `false`
+
+This overrides this task from blocking deletion of folders outside current working dir (CWD). Use with caution.
+
+## no-write
+Type: `Boolean`
+Default: `false`
+
+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._
diff --git a/docs/clean-overview.md b/docs/clean-overview.md
new file mode 100644
index 0000000..62f8365
--- /dev/null
+++ b/docs/clean-overview.md
@@ -0,0 +1,3 @@
+Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.
+
+*Due to the destructive nature of this task, always be cautious of the paths you clean.*
\ No newline at end of file
diff --git a/docs/overview.md b/docs/overview.md
new file mode 100644
index 0000000..d8014b6
--- /dev/null
+++ b/docs/overview.md
@@ -0,0 +1 @@
+*This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-clean/tree/grunt-0.3-stable).*
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..79a90c4
--- /dev/null
+++ b/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "grunt-contrib-clean",
+ "description": "Clean files and folders",
+ "version": "1.0.0",
+ "author": {
+ "name": "Grunt Team",
+ "url": "http://gruntjs.com/"
+ },
+ "repository": "gruntjs/grunt-contrib-clean",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "main": "tasks/clean.js",
+ "scripts": {
+ "test": "grunt test"
+ },
+ "dependencies": {
+ "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.12.0",
+ "grunt-contrib-nodeunit": "^0.4.1"
+ },
+ "peerDependencies": {
+ "grunt": ">= 0.4.5"
+ },
+ "keywords": [
+ "gruntplugin",
+ "clean",
+ "cleanup",
+ "remove",
+ "delete",
+ "del",
+ "rm",
+ "rmrf",
+ "rimraf"
+ ],
+ "files": [
+ "tasks"
+ ],
+ "appveyor_id": "li28411ceq3n833d"
+}
diff --git a/tasks/clean.js b/tasks/clean.js
new file mode 100644
index 0000000..c5d8e02
--- /dev/null
+++ b/tasks/clean.js
@@ -0,0 +1,67 @@
+/*
+ * grunt-contrib-clean
+ * http://gruntjs.com/
+ *
+ * Copyright (c) 2016 Tim Branyen, contributors
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+var async = require('async');
+var rimraf = require('rimraf');
+
+module.exports = function(grunt) {
+
+ function clean(filepath, options, done) {
+ if (!grunt.file.exists(filepath)) {
+ return done();
+ }
+
+ // Only delete cwd or outside cwd if --force enabled. Be careful, people!
+ if (!options.force) {
+ if (grunt.file.isPathCwd(filepath)) {
+ grunt.verbose.error();
+ grunt.fail.warn('Cannot delete the current working directory.');
+ return done();
+ } else if (!grunt.file.isPathInCwd(filepath)) {
+ grunt.verbose.error();
+ grunt.fail.warn('Cannot delete files outside the current working directory.');
+ return done();
+ }
+ }
+
+ 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);
+ }
+ done();
+ });
+ }
+
+ grunt.registerMultiTask('clean', 'Clean files and folders.', function() {
+ // Merge task-specific and/or target-specific options with these defaults.
+ var options = this.options({
+ force: grunt.option('force') === true,
+ 'no-write': grunt.option('no-write') === true
+ });
+
+ var done = this.async();
+
+ // Clean specified files / dirs.
+ 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);
+ });
+ });
+
+};
diff --git a/test/clean_test.js b/test/clean_test.js
new file mode 100644
index 0000000..d3567c0
--- /dev/null
+++ b/test/clean_test.js
@@ -0,0 +1,33 @@
+'use strict';
+
+var grunt = require('grunt');
+var dircompare = require('dir-compare');
+
+exports.clean = {
+ shortPathTest: function(test) {
+ test.expect(1);
+
+ var expected = grunt.file.exists('tmp/sample_short');
+ test.equal(expected, false, 'should remove the short directory using clean');
+
+ test.done();
+ },
+ longPathTest: function(test) {
+ test.expect(1);
+
+ var expected = grunt.file.exists('tmp/sample_long');
+ test.equal(expected, false, 'should remove the long directory using clean');
+
+ test.done();
+ },
+ exclude: function (test) {
+ var res = dircompare.compareSync('test/expected/end_01', 'tmp/end_01');
+ test.equal(true, res.same, 'should match exclusions');
+ test.done();
+ },
+ excludeSub: function (test) {
+ var res = dircompare.compareSync('test/expected/end_02', 'tmp/end_02');
+ test.equal(true, res.same, 'should match exclusions for sub');
+ test.done();
+ }
+};
diff --git a/test/expected/end_01/1.txt b/test/expected/end_01/1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/expected/end_02/2/1.txt b/test/expected/end_02/2/1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/sample_long/long.txt b/test/fixtures/sample_long/long.txt
new file mode 100644
index 0000000..83f9fcf
--- /dev/null
+++ b/test/fixtures/sample_long/long.txt
@@ -0,0 +1 @@
+txt
diff --git a/test/fixtures/sample_short/short.txt b/test/fixtures/sample_short/short.txt
new file mode 100644
index 0000000..83f9fcf
--- /dev/null
+++ b/test/fixtures/sample_short/short.txt
@@ -0,0 +1 @@
+txt
diff --git a/test/fixtures/start/1.txt b/test/fixtures/start/1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/start/2.txt b/test/fixtures/start/2.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/start/2/1.txt b/test/fixtures/start/2/1.txt
new file mode 100644
index 0000000..e69de29
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-grunt-contrib-clean.git
More information about the Pkg-javascript-commits
mailing list