Drop dependency on deprecated `gulp-util`

Closes dlmanning/gulp-sass#646
master
Charles Samborski 2017-12-29 18:42:22 +01:00 committed by xzyfer
parent 9a8a8797ca
commit e61535250e
3 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,9 @@
'use strict';
var gutil = require('gulp-util');
var chalk = require('chalk');
var PluginError = require('plugin-error');
var replaceExtension = require('replace-ext');
var stripAnsi = require('strip-ansi');
var through = require('through2');
var clonedeep = require('lodash.clonedeep');
var path = require('path');
@ -23,13 +26,13 @@ var gulpSass = function gulpSass(options, sync) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
}
if (path.basename(file.path).indexOf('_') === 0) {
return cb();
}
if (!file.contents.length) {
file.path = gutil.replaceExtension(file.path, '.css');
file.path = replaceExtension(file.path, '.css');
return cb(null, file);
}
@ -100,13 +103,13 @@ var gulpSass = function gulpSass(options, sync) {
});
// Replace the map file with the original file name (but new extension)
sassMap.file = gutil.replaceExtension(sassFileSrc, '.css');
sassMap.file = replaceExtension(sassFileSrc, '.css');
// Apply the map
applySourceMap(file, sassMap);
}
file.contents = sassObj.css;
file.path = gutil.replaceExtension(file.path, '.css');
file.path = replaceExtension(file.path, '.css');
cb(null, file);
};
@ -122,16 +125,16 @@ var gulpSass = function gulpSass(options, sync) {
filePath = filePath ? filePath : file.path;
relativePath = path.relative(process.cwd(), filePath);
message += gutil.colors.underline(relativePath) + '\n';
message += chalk.underline(relativePath) + '\n';
message += error.formatted;
error.messageFormatted = message;
error.messageOriginal = error.message;
error.message = gutil.colors.stripColor(message);
error.message = stripAnsi(message);
error.relativePath = relativePath;
return cb(new gutil.PluginError(
return cb(new PluginError(
PLUGIN_NAME, error
));
};
@ -176,7 +179,7 @@ gulpSass.sync = function sync(options) {
// Log errors nicely
//////////////////////////////
gulpSass.logError = function logError(error) {
var message = new gutil.PluginError('sass', error.messageFormatted).toString();
var message = new PluginError('sass', error.messageFormatted).toString();
process.stderr.write(message + '\n');
this.emit('end');
};

View File

@ -24,9 +24,12 @@
"url": "https://github.com/dlmanning/gulp-sass/issues"
},
"dependencies": {
"gulp-util": "^3.0",
"chalk": "^2.3.0",
"lodash.clonedeep": "^4.3.2",
"node-sass": "^4.8.3",
"plugin-error": "^1.0.1",
"replace-ext": "^1.0.0",
"strip-ansi": "^4.0.0",
"through2": "^2.0.0",
"vinyl-sourcemaps-apply": "^0.2.0"
},
@ -40,6 +43,7 @@
"gulp-tap": "^0.1.3",
"mocha": "^2.2.1",
"rimraf": "^2.4.3",
"should": "^8.3.1"
"should": "^8.3.1",
"vinyl": "^2.1.0"
}
}

View File

@ -1,7 +1,7 @@
'use strict';
var should = require('should');
var gutil = require('gulp-util');
var Vinyl = require('vinyl');
var path = require('path');
var fs = require('fs');
var sass = require('../index');
@ -17,7 +17,7 @@ var createVinyl = function createVinyl(filename, contents) {
var base = path.join(__dirname, 'scss');
var filePath = path.join(base, filename);
return new gutil.File({
return new Vinyl({
'cwd': __dirname,
'base': base,
'path': filePath,