Skip to content

Commit

Permalink
remove gulp-util
Browse files Browse the repository at this point in the history
  • Loading branch information
邝业亨 committed Jan 10, 2018
1 parent b4c1fcf commit d83c56a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
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) {
Expand All @@ -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();
}
Expand Down
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",
Expand All @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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',
Expand All @@ -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/'
Expand All @@ -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/'
Expand All @@ -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
}));
Expand Down Expand Up @@ -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/')
}));
Expand Down Expand Up @@ -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/')
}));
Expand All @@ -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/')
}));
Expand Down
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')
};

0 comments on commit d83c56a

Please sign in to comment.