gulp-clean
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -5,12 +5,13 @@ 'use strict'; | ||
var gutil = require('gulp-util'); | ||
var path = require('path'); | ||
module.exports = function (options) { | ||
return es.map(function (file, cb) { | ||
return es.map(function (file, cb) { | ||
// Paths are resolved by gulp | ||
var filepath = file.path; | ||
var cwd = file.cwd; | ||
var starts = new RegExp('^' + cwd + '/'); | ||
var relative = path.relative(cwd, filepath); | ||
// Prevent mistakes with paths | ||
if (starts.test(filepath) && filepath !== cwd || (options ? (options.force && typeof options.force === 'boolean') : false)) { | ||
if (!(relative.substr(0, 2) === '..') && relative !== '' || (options ? (options.force && typeof options.force === 'boolean') : false)) { | ||
rimraf(filepath, function (error) { | ||
@@ -23,3 +24,3 @@ if (!error) { | ||
}); | ||
} else if (filepath === cwd) { | ||
} else if (relative === '') { | ||
gutil.log('gulp-clean: Cannot delete current working directory. (' + filepath + ')'); | ||
@@ -26,0 +27,0 @@ cb(null, file); |
{ | ||
"name": "gulp-clean", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A gulp plugin for removing files and folders.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -41,26 +41,4 @@ # [gulp](https://github.com/wearefractal/gulp)-clean [![Build Status](https://secure.travis-ci.org/peter-vilja/gulp-clean.png?branch=master)](https://travis-ci.org/peter-vilja/gulp-clean) [![NPM version](https://badge.fury.io/js/gulp-clean.png)](http://badge.fury.io/js/gulp-clean) | ||
## Changelog | ||
This Changelog follows [Semantic Versioning](http://semver.org). | ||
* **0.2.1** | ||
* Type check for force option's value | ||
* **0.2.0** | ||
* Support for option force, to allow removing files and folders outside the current working directory. | ||
* Fixed a bug, which made it possible to remove files/folders starting with the project's name to be removed outside the current working directory. | ||
* **0.1.3** | ||
* Improved documentation. | ||
* Rewrote tests. | ||
* **0.1.2** | ||
* Improved documentation. | ||
* Fixed a bug in tests. | ||
* **0.1.1** | ||
* Improved documentation. | ||
* **0.1.0** | ||
* Possibility to remove files and folders from given paths. | ||
* Don't remove current working directory. | ||
* Don't remove anything from outside the current working directory. | ||
## License | ||
[MIT](http://en.wikipedia.org/wiki/MIT_License) @ Peter Vilja |
@@ -132,3 +132,3 @@ /*global describe, before, it*/ | ||
stream.write(new gutil.File({ | ||
cwd: path.resolve(cwd + '..'), | ||
cwd: path.resolve(cwd), | ||
path: path.resolve(cwd + '/../secrets/') | ||
@@ -155,3 +155,3 @@ })); | ||
stream.write(new gutil.File({ | ||
cwd: path.resolve(cwd + '..'), | ||
cwd: path.resolve(cwd), | ||
path: path.resolve(cwd + '/../gulp-cleanTemp/') | ||
@@ -176,3 +176,3 @@ })); | ||
stream.write(new gutil.File({ | ||
cwd: path.resolve(cwd + '..'), | ||
cwd: path.resolve(cwd), | ||
path: path.resolve(cwd + '/../gulp-cleanTemp/') | ||
@@ -179,0 +179,0 @@ })); |
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
174
7976
44