在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):gulpjs/gulp-util开源软件地址(OpenSource Url):https://github.com/gulpjs/gulp-util开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):This module has been deprecated. More information at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 Here are some things you can use instead:
gulp-utilInformation
Usagevar gutil = require('gulp-util');
gutil.log('stuff happened', 'Really it did', gutil.colors.magenta('123'));
gutil.replaceExtension('file.coffee', '.js'); // file.js
var opt = {
name: 'todd',
file: someGulpFile
};
gutil.template('test <%= name %> <%= file.path %>', opt) // test todd /js/hi.js log(msg...)Logs stuff. Already prefixed with [gulp] and all that. If you pass in multiple arguments it will join them by a space. The default gulp coloring using gutil.colors.:
colorsIs an instance of chalk. replaceExtension(path, newExtension)Replaces a file extension in a path. Returns the new path. isStream(obj)Returns true or false if an object is a stream. isBuffer(obj)Returns true or false if an object is a Buffer. template(string[, data])This is a lodash.template function wrapper. You must pass in a valid gulp file object so it is available to the user or it will error. You can not configure any of the delimiters. Look at the lodash docs for more info. new File(obj)This is just vinyl var file = new gutil.File({
base: path.join(__dirname, './fixtures/'),
cwd: __dirname,
path: path.join(__dirname, './fixtures/test.coffee')
}); noop()Returns a stream that does nothing but pass data straight through. // gulp should be called like this :
// $ gulp --type production
gulp.task('scripts', function() {
gulp.src('src/**/*.js')
.pipe(concat('script.js'))
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(gulp.dest('dist/'));
}); buffer(cb)This is similar to es.wait but instead of buffering text into one string it buffers anything into an array (so very useful for file objects). Returns a stream that can be piped to. The stream will emit one data event after the stream piped to it has ended. The data will be the same array passed to the callback. Callback is optional and receives two arguments: error and data gulp.src('stuff/*.js')
.pipe(gutil.buffer(function(err, files) {
})); new PluginError(pluginName, message[, options])
These are all acceptable forms of instantiation: var err = new gutil.PluginError('test', {
message: 'something broke'
});
var err = new gutil.PluginError({
plugin: 'test',
message: 'something broke'
});
var err = new gutil.PluginError('test', 'something broke');
var err = new gutil.PluginError('test', 'something broke', {showStack: true});
var existingError = new Error('OMG');
var err = new gutil.PluginError('test', existingError, {showStack: true}); gulp-util for enterpriseAvailable as part of the Tidelift Subscription The maintainers of gulp-util and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论