{"id":15207248,"url":"https://github.com/gulpjs/gulp-util","last_synced_at":"2025-10-21T19:08:16.160Z","repository":{"id":52566097,"uuid":"11214932","full_name":"gulpjs/gulp-util","owner":"gulpjs","description":"[deprecated] - See https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5","archived":true,"fork":false,"pushed_at":"2020-10-31T11:18:21.000Z","size":140,"stargazers_count":830,"open_issues_count":0,"forks_count":104,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-10-30T00:55:58.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":["phated"],"tidelift":"npm/gulp-util","open_collective":"gulpjs"}},"created_at":"2013-07-06T07:35:39.000Z","updated_at":"2024-09-19T01:18:54.000Z","dependencies_parsed_at":"2022-09-10T22:31:40.998Z","dependency_job_id":null,"html_url":"https://github.com/gulpjs/gulp-util","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fgulp-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fgulp-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fgulp-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fgulp-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/gulp-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235059234,"owners_count":18929279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-28T06:40:46.470Z","updated_at":"2025-10-03T01:30:38.756Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/phated","https://tidelift.com/funding/github/npm/gulp-util","https://opencollective.com/gulpjs","https://tidelift.com/subscription/pkg/npm-gulp-util?utm_source=npm-gulp-util\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["Plugins","插件"],"sub_categories":["Miscellaneous Plugins","其他插件"],"readme":"__This module has been deprecated. More information at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5__\n\n__Here are some things you can use instead:__\n\n* `gutil.File` =\u003e https://www.npmjs.com/package/vinyl\n* `gutil.replaceExtension` =\u003e The `.extname` property on vinyl objects or https://www.npmjs.com/package/replace-ext\n* `gutil.colors` =\u003e https://www.npmjs.com/package/ansi-colors\n* `gutil.date` =\u003e https://www.npmjs.com/package/date-format\n* `gutil.log` =\u003e https://www.npmjs.com/package/fancy-log\n* `gutil.template` =\u003e https://www.npmjs.com/package/lodash.template\n* `gutil.env` =\u003e https://www.npmjs.com/package/minimist\n* `gutil.beep` =\u003e https://www.npmjs.com/package/beeper\n* `gutil.noop` =\u003e https://www.npmjs.com/package/through2\n* `gutil.isStream` =\u003e Use the `.isStream()` method on vinyl objects\n* `gutil.isBuffer` =\u003e Use the `.isBuffer()` method on vinyl objects\n* `gutil.isNull` =\u003e Use the `.isNull()` method on vinyl objects\n* `gutil.linefeed` =\u003e Use the string `'\\n'` in your code\n* `gutil.combine` =\u003e https://www.npmjs.com/package/multipipe\n* `gutil.buffer` =\u003e https://www.npmjs.com/package/list-stream\n* `gutil.PluginError` =\u003e https://www.npmjs.com/package/plugin-error\n\n# gulp-util [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url]\n\n## Information\n\n\u003ctable\u003e\n\u003ctr\u003e \n\u003ctd\u003ePackage\u003c/td\u003e\u003ctd\u003egulp-util\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eDescription\u003c/td\u003e\n\u003ctd\u003eUtility functions for gulp plugins\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eNode Version\u003c/td\u003e\n\u003ctd\u003e\u003e= 0.10\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## Usage\n\n```javascript\nvar gutil = require('gulp-util');\n\ngutil.log('stuff happened', 'Really it did', gutil.colors.magenta('123'));\n\ngutil.replaceExtension('file.coffee', '.js'); // file.js\n\nvar opt = {\n  name: 'todd',\n  file: someGulpFile\n};\ngutil.template('test \u003c%= name %\u003e \u003c%= file.path %\u003e', opt) // test todd /js/hi.js\n```\n\n### log(msg...)\n\nLogs stuff. Already prefixed with [gulp] and all that. If you pass in multiple arguments it will join them by a space.\n\nThe default gulp coloring using gutil.colors.\u003ccolor\u003e:\n```\nvalues (files, module names, etc.) = cyan\nnumbers (times, counts, etc) = magenta\n```\n\n### colors\n\nIs an instance of [chalk](https://github.com/sindresorhus/chalk).\n\n### replaceExtension(path, newExtension)\n\nReplaces a file extension in a path. Returns the new path.\n\n### isStream(obj)\n\nReturns true or false if an object is a stream.\n\n### isBuffer(obj)\n\nReturns true or false if an object is a Buffer.\n\n### template(string[, data])\n\nThis 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](http://lodash.com/docs#template) for more info.\n\n## new File(obj)\n\nThis is just [vinyl](https://github.com/wearefractal/vinyl)\n\n```javascript\nvar file = new gutil.File({\n  base: path.join(__dirname, './fixtures/'),\n  cwd: __dirname,\n  path: path.join(__dirname, './fixtures/test.coffee')\n});\n```\n\n## noop()\n\nReturns a stream that does nothing but pass data straight through.\n\n```javascript\n// gulp should be called like this :\n// $ gulp --type production\ngulp.task('scripts', function() {\n  gulp.src('src/**/*.js')\n    .pipe(concat('script.js'))\n    .pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())\n    .pipe(gulp.dest('dist/'));\n});\n```\n\n## buffer(cb)\n\nThis 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).\n\nReturns a stream that can be piped to.\n\nThe 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.\n\nCallback is optional and receives two arguments: error and data\n\n```javascript\ngulp.src('stuff/*.js')\n  .pipe(gutil.buffer(function(err, files) {\n  \n  }));\n```\n\n## new PluginError(pluginName, message[, options])\n\n- pluginName should be the module name of your plugin\n- message can be a string or an existing error\n- By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.\n- If you pass an error in as the message the stack will be pulled from that, otherwise one will be created.\n- Note that if you pass in a custom stack string you need to include the message along with that.\n- Error properties will be included in `err.toString()`. Can be omitted by including `{showProperties: false}` in the options.\n\nThese are all acceptable forms of instantiation:\n\n```javascript\nvar err = new gutil.PluginError('test', {\n  message: 'something broke'\n});\n\nvar err = new gutil.PluginError({\n  plugin: 'test',\n  message: 'something broke'\n});\n\nvar err = new gutil.PluginError('test', 'something broke');\n\nvar err = new gutil.PluginError('test', 'something broke', {showStack: true});\n\nvar existingError = new Error('OMG');\nvar err = new gutil.PluginError('test', existingError, {showStack: true});\n```\n\n## gulp-util for enterprise\n\nAvailable as part of the Tidelift Subscription\n\nThe 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.](https://tidelift.com/subscription/pkg/npm-gulp-util?utm_source=npm-gulp-util\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n\n\n[npm-url]: https://www.npmjs.com/package/gulp-util\n[npm-image]: https://badge.fury.io/js/gulp-util.svg\n[travis-url]: https://travis-ci.org/gulpjs/gulp-util\n[travis-image]: https://img.shields.io/travis/gulpjs/gulp-util.svg?branch=master\n[coveralls-url]: https://coveralls.io/r/gulpjs/gulp-util\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/gulp-util.svg\n[depstat-url]: https://david-dm.org/gulpjs/gulp-util\n[depstat-image]: https://david-dm.org/gulpjs/gulp-util.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fgulp-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fgulp-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fgulp-util/lists"}