Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: peter-vilja/gulp-clean
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.2
Choose a base ref
...
head repository: peter-vilja/gulp-clean
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.0
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Jan 10, 2018

  1. remove gulp-util

    邝业亨 committed Jan 10, 2018
    Copy the full SHA
    d83c56a View commit details
  2. Copy the full SHA
    1b2503e View commit details
Showing with 28 additions and 20 deletions.
  1. +2 −1 .gitignore
  2. +6 −6 index.js
  3. +6 −4 package.json
  4. +9 −9 test.js
  5. +5 −0 utils.js
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
tmp/
.DS_Store
.DS_Store
/.idea
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
var rimraf = require('rimraf');
var through2 = require('through2');
var gutil = require('gulp-util');
var utils = require('./utils');
var path = require('path');

module.exports = function (options) {
@@ -15,21 +15,21 @@ module.exports = function (options) {
if (!(relative.substr(0, 2) === '..') && relative !== '' || (options ? (options.force && typeof options.force === 'boolean') : false)) {
rimraf(filepath, function (error) {
if (error) {
this.emit('error', new gutil.PluginError('gulp-clean', 'Unable to delete "' + filepath + '" file (' + error.message + ').'));
this.emit('error', new utils.PluginError('gulp-clean', 'Unable to delete "' + filepath + '" file (' + error.message + ').'));
}
this.push(file);
cb();
}.bind(this));
} else if (relative === '') {
var msgCurrent = 'Cannot delete current working directory. (' + filepath + '). Use option force.';
gutil.log('gulp-clean: ' + msgCurrent);
this.emit('error', new gutil.PluginError('gulp-clean', msgCurrent));
utils.log('gulp-clean: ' + msgCurrent);
this.emit('error', new utils.PluginError('gulp-clean', msgCurrent));
this.push(file);
cb();
} else {
var msgOutside = 'Cannot delete files outside the current working directory. (' + filepath + '). Use option force.';
gutil.log('gulp-clean: ' + msgOutside);
this.emit('error', new gutil.PluginError('gulp-clean', msgOutside));
utils.log('gulp-clean: ' + msgOutside);
this.emit('error', new utils.PluginError('gulp-clean', msgOutside));
this.push(file);
cb();
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-clean",
"version": "0.3.2",
"version": "0.4.0",
"description": "A gulp plugin for removing files and folders.",
"keywords": [
"gulpplugin",
@@ -23,9 +23,11 @@
"test": "mocha test.js"
},
"dependencies": {
"rimraf": "^2.2.8",
"gulp-util": "^2.2.14",
"through2": "^0.4.2"
"fancy-log": "^1.3.2",
"plugin-error": "^0.1.2",
"rimraf": "^2.6.2",
"through2": "^2.0.3",
"vinyl": "^2.1.0"
},
"devDependencies": {
"mocha": "^1.19.0",
18 changes: 9 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
'use strict';
var fs = require('fs');
var path = require('path');
var gutil = require('gulp-util');
var clean = require('./');
var utils = require('./utils');
var clean = require('./index');
var expect = require('chai').expect;

function noop() {}
@@ -45,7 +45,7 @@ describe('gulp-clean plugin', function () {
});
});

stream.write(new gutil.File({
stream.write(new utils.File({
cwd: cwd,
base: cwd + '/tmp/',
path: cwd + '/tmp/test.js',
@@ -67,7 +67,7 @@ describe('gulp-clean plugin', function () {
});
});

stream.write(new gutil.File({
stream.write(new utils.File({
cwd: cwd,
base: cwd + '/tmp/',
path: cwd + '/tmp/test/'
@@ -91,7 +91,7 @@ describe('gulp-clean plugin', function () {
});
});
stream.on('data', noop);
stream.write(new gutil.File({
stream.write(new utils.File({
cwd: cwd,
base: cwd + '/tmp',
path: cwd + '/tmp/tree/'
@@ -118,7 +118,7 @@ describe('gulp-clean plugin', function () {
});

stream.on('data', noop);
stream.write(new gutil.File({
stream.write(new utils.File({
cwd: cwd,
path: cwd
}));
@@ -146,7 +146,7 @@ describe('gulp-clean plugin', function () {

stream.on('data', noop);

stream.write(new gutil.File({
stream.write(new utils.File({
cwd: path.resolve(cwd),
path: path.resolve(cwd + '/../secrets/')
}));
@@ -176,7 +176,7 @@ describe('gulp-clean plugin', function () {
});
});

stream.write(new gutil.File({
stream.write(new utils.File({
cwd: path.resolve(cwd),
path: path.resolve(cwd + '/../gulp-cleanTemp/')
}));
@@ -196,7 +196,7 @@ describe('gulp-clean plugin', function () {
});
});

stream.write(new gutil.File({
stream.write(new utils.File({
cwd: path.resolve(cwd),
path: path.resolve(cwd + '/../gulp-cleanTemp/')
}));
5 changes: 5 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
PluginError: require('plugin-error'),
log: require('fancy-log'),
File: require('vinyl')
};