Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,20 @@
Copyright (c) 2014 Fractal <contact@wearefractal.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,140 @@
# 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]
## Information
<table>
<tr>
<td>Package</td><td>gulp-util</td>
</tr>
<tr>
<td>Description</td>
<td>Utility functions for gulp plugins</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.9</td>
</tr>
</table>
## Usage
```javascript
var gutil = require('gulp-util');
gutil.log('stuff happened', 'Really it did', gutil.colors.cyan('123'));
gutil.beep();
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. Use the right colors for values. If you pass in multiple arguments it will join them by a space.
```
values (files, module names, etc.) = magenta
numbers (times, counts, etc) = cyan
```
### 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](http://lodash.com/docs#template) for more info.
## new File(obj)
This is just [vinyl](https://github.com/wearefractal/vinyl)
```javascript
var file = new gutil.File({
base: join(__dirname, './fixtures/'),
cwd: __dirname,
path: join(__dirname, './fixtures/test.coffee')
});
```
## noop()
Returns a stream that does nothing but pass data straight through.
```javascript
// 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
```javascript
gulp.src('stuff/*.js')
.pipe(gutil.buffer(function(err, files){
});
```
## new PluginError(pluginName, message[, options])
- pluginName should be the module name of your plugin
- message can be a string or an existing error
- By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
- If you pass an error in as the message the stack will be pulled from that, otherwise one will be created.
- Note that if you pass in a custom stack string you need to include the message along with that.
These are all acceptable forms of instantiation:
```javascript
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});
```
[npm-url]: https://npmjs.org/package/gulp-util
[npm-image]: https://badge.fury.io/js/gulp-util.svg
[travis-url]: https://travis-ci.org/gulpjs/gulp-util
[travis-image]: https://travis-ci.org/gulpjs/gulp-util.svg?branch=master
[coveralls-url]: https://coveralls.io/r/gulpjs/gulp-util
[coveralls-image]: https://coveralls.io/repos/gulpjs/gulp-util/badge.png
[depstat-url]: https://david-dm.org/gulpjs/gulp-util
[depstat-image]: https://david-dm.org/gulpjs/gulp-util.svg

View File

@ -0,0 +1,18 @@
module.exports = {
File: require('./lib/File'),
replaceExtension: require('./lib/replaceExtension'),
colors: require('./lib/colors'),
date: require('./lib/date'),
log: require('./lib/log'),
template: require('./lib/template'),
env: require('./lib/env'),
beep: require('./lib/beep'),
noop: require('./lib/noop'),
isStream: require('./lib/isStream'),
isBuffer: require('./lib/isBuffer'),
isNull: require('./lib/isNull'),
linefeed: require('./lib/linefeed'),
combine: require('./lib/combine'),
buffer: require('./lib/buffer'),
PluginError: require('./lib/PluginError')
};

View File

@ -0,0 +1 @@
module.exports = require('vinyl');

View File

@ -0,0 +1,64 @@
var util = require('util');
var colors = require('./colors');
// wow what a clusterfuck
var parseOptions = function(plugin, message, opt) {
if (!opt) opt = {};
if (typeof plugin === 'object') {
opt = plugin;
} else if (message instanceof Error) {
opt.error = message;
opt.plugin = plugin;
} else if (typeof message === 'object') {
opt = message;
opt.plugin = plugin;
} else if (typeof opt === 'object') {
opt.plugin = plugin;
opt.message = message;
}
return opt;
};
function PluginError(plugin, message, opt) {
if (!(this instanceof PluginError)) throw new Error('Call PluginError using new');
Error.call(this);
var options = parseOptions(plugin, message, opt);
this.plugin = options.plugin;
this.showStack = options.showStack === true;
var properties = ['name', 'message', 'fileName', 'lineNumber', 'stack'];
// if options has an error, grab details from it
if (options.error) {
properties.forEach(function(prop) {
if (prop in options.error) this[prop] = options.error[prop];
}, this);
}
// options object can override
properties.forEach(function(prop) {
if (prop in options) this[prop] = options[prop];
}, this);
// defaults
if (!this.name) this.name = 'Error';
// TODO: figure out why this explodes mocha
if (!this.stack) Error.captureStackTrace(this, arguments.callee || this.constructor);
if (!this.plugin) throw new Error('Missing plugin name');
if (!this.message) throw new Error('Missing error message');
}
util.inherits(PluginError, Error);
PluginError.prototype.toString = function () {
var sig = this.name+' in plugin \''+colors.cyan(this.plugin)+'\'';
var msg = this.showStack ? (this._stack || this.stack) : this.message;
return sig+'\n'+msg;
};
module.exports = PluginError;

View File

@ -0,0 +1,3 @@
module.exports = function() {
process.stdout.write('\x07');
};

View File

@ -0,0 +1,15 @@
var through = require('through2');
module.exports = function(fn) {
var buf = [];
var end = function(cb) {
this.push(buf);
cb();
if(fn) fn(null, buf);
};
var push = function(data, enc, cb) {
buf.push(data);
cb();
};
return through.obj(push, end);
};

View File

@ -0,0 +1 @@
module.exports = require('chalk');

View File

@ -0,0 +1,11 @@
var pipeline = require('multipipe');
module.exports = function(){
var args = arguments;
if (args.length === 1 && Array.isArray(args[0])) {
args = args[0];
}
return function(){
return pipeline.apply(pipeline, args);
};
};

View File

@ -0,0 +1 @@
module.exports = require('dateformat');

View File

@ -0,0 +1,4 @@
var parseArgs = require('minimist');
var argv = parseArgs(process.argv.slice(2));
module.exports = argv;

View File

@ -0,0 +1,7 @@
var buf = require('buffer');
var Buffer = buf.Buffer;
// could use Buffer.isBuffer but this is the same exact thing...
module.exports = function(o) {
return typeof o === 'object' && o instanceof Buffer;
};

View File

@ -0,0 +1,3 @@
module.exports = function(v) {
return v === null;
};

View File

@ -0,0 +1,5 @@
var Stream = require('stream').Stream;
module.exports = function(o) {
return !!o && o instanceof Stream;
};

View File

@ -0,0 +1 @@
module.exports = '\n';

View File

@ -0,0 +1,10 @@
var colors = require('./colors');
var date = require('./date');
module.exports = function(){
var time = '['+colors.grey(date(new Date(), 'HH:MM:ss'))+']';
var args = Array.prototype.slice.call(arguments);
args.unshift(time);
console.log.apply(console, args);
return this;
};

View File

@ -0,0 +1,5 @@
var through = require('through2');
module.exports = function () {
return through.obj();
};

View File

@ -0,0 +1,9 @@
var path = require('path');
module.exports = function(npath, ext) {
if (typeof npath !== 'string') return npath;
if (npath.length === 0) return npath;
var nFileName = path.basename(npath, path.extname(npath))+ext;
return path.join(path.dirname(npath), nFileName);
};

View File

@ -0,0 +1,19 @@
var template = require('lodash.template');
var reInterpolate = require('lodash._reinterpolate');
var forcedSettings = {
escape: /<%-([\s\S]+?)%>/g,
evaluate: /<%([\s\S]+?)%>/g,
interpolate: reInterpolate
};
module.exports = function(tmpl, data){
var fn = template(tmpl, null, forcedSettings);
var wrapped = function(o) {
if (typeof o === 'undefined' || typeof o.file === 'undefined') throw new Error('Failed to provide the current file as "file" to the template');
return fn(o);
};
return (data ? wrapped(data) : wrapped);
};

View File

@ -0,0 +1,79 @@
{
"_from": "gulp-util@~2.2.14",
"_id": "gulp-util@2.2.20",
"_inBundle": false,
"_integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=",
"_location": "/gulp-spawn/gulp-util",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "gulp-util@~2.2.14",
"name": "gulp-util",
"escapedName": "gulp-util",
"rawSpec": "~2.2.14",
"saveSpec": null,
"fetchSpec": "~2.2.14"
},
"_requiredBy": [
"/gulp-spawn"
],
"_resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz",
"_shasum": "d7146e5728910bd8f047a6b0b1e549bc22dbd64c",
"_spec": "gulp-util@~2.2.14",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/gulp-spawn",
"author": {
"name": "Fractal",
"email": "contact@wearefractal.com",
"url": "http://wearefractal.com/"
},
"bugs": {
"url": "https://github.com/wearefractal/gulp-util/issues"
},
"bundleDependencies": false,
"dependencies": {
"chalk": "^0.5.0",
"dateformat": "^1.0.7-1.2.3",
"lodash._reinterpolate": "^2.4.1",
"lodash.template": "^2.4.1",
"minimist": "^0.2.0",
"multipipe": "^0.1.0",
"through2": "^0.5.0",
"vinyl": "^0.2.1"
},
"deprecated": false,
"description": "Utility functions for gulp plugins",
"devDependencies": {
"buffer-equal": "~0.0.1",
"coveralls": "^2.7.0",
"event-stream": "^3.1.0",
"istanbul": "^0.2.3",
"jshint": "^2.4.1",
"lodash.templatesettings": "^2.4.1",
"mocha": "^1.17.0",
"mocha-lcov-reporter": "^0.0.1",
"rimraf": "^2.2.5",
"should": "^4.0.0"
},
"engines": {
"node": ">= 0.9"
},
"homepage": "http://github.com/wearefractal/gulp-util",
"licenses": [
{
"type": "MIT",
"url": "http://github.com/wearefractal/gulp-util/raw/master/LICENSE"
}
],
"main": "./index.js",
"name": "gulp-util",
"repository": {
"type": "git",
"url": "git://github.com/wearefractal/gulp-util.git"
},
"scripts": {
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"test": "mocha --reporter spec && jshint"
},
"version": "2.2.20"
}