diff options
Diffstat (limited to 'node_modules/gulp-util/lib')
-rw-r--r-- | node_modules/gulp-util/lib/File.js | 1 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/PluginError.js | 64 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/beep.js | 3 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/buffer.js | 15 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/colors.js | 1 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/combine.js | 11 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/date.js | 1 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/env.js | 4 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/isBuffer.js | 7 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/isNull.js | 3 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/isStream.js | 5 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/linefeed.js | 1 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/log.js | 10 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/noop.js | 5 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/replaceExtension.js | 9 | ||||
-rw-r--r-- | node_modules/gulp-util/lib/template.js | 19 |
16 files changed, 159 insertions, 0 deletions
diff --git a/node_modules/gulp-util/lib/File.js b/node_modules/gulp-util/lib/File.js new file mode 100644 index 000000000..690a508a6 --- /dev/null +++ b/node_modules/gulp-util/lib/File.js @@ -0,0 +1 @@ +module.exports = require('vinyl');
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/PluginError.js b/node_modules/gulp-util/lib/PluginError.js new file mode 100644 index 000000000..6640346ed --- /dev/null +++ b/node_modules/gulp-util/lib/PluginError.js @@ -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; diff --git a/node_modules/gulp-util/lib/beep.js b/node_modules/gulp-util/lib/beep.js new file mode 100644 index 000000000..5473d7548 --- /dev/null +++ b/node_modules/gulp-util/lib/beep.js @@ -0,0 +1,3 @@ +module.exports = function() { + process.stdout.write('\x07'); +}; diff --git a/node_modules/gulp-util/lib/buffer.js b/node_modules/gulp-util/lib/buffer.js new file mode 100644 index 000000000..4cb064aca --- /dev/null +++ b/node_modules/gulp-util/lib/buffer.js @@ -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); +};
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/colors.js b/node_modules/gulp-util/lib/colors.js new file mode 100644 index 000000000..bc8049406 --- /dev/null +++ b/node_modules/gulp-util/lib/colors.js @@ -0,0 +1 @@ +module.exports = require('chalk');
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/combine.js b/node_modules/gulp-util/lib/combine.js new file mode 100644 index 000000000..f20712d20 --- /dev/null +++ b/node_modules/gulp-util/lib/combine.js @@ -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); + }; +}; diff --git a/node_modules/gulp-util/lib/date.js b/node_modules/gulp-util/lib/date.js new file mode 100644 index 000000000..935793cc6 --- /dev/null +++ b/node_modules/gulp-util/lib/date.js @@ -0,0 +1 @@ +module.exports = require('dateformat');
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/env.js b/node_modules/gulp-util/lib/env.js new file mode 100644 index 000000000..ea1e03e4a --- /dev/null +++ b/node_modules/gulp-util/lib/env.js @@ -0,0 +1,4 @@ +var parseArgs = require('minimist'); +var argv = parseArgs(process.argv.slice(2)); + +module.exports = argv;
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/isBuffer.js b/node_modules/gulp-util/lib/isBuffer.js new file mode 100644 index 000000000..0e23782c4 --- /dev/null +++ b/node_modules/gulp-util/lib/isBuffer.js @@ -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; +};
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/isNull.js b/node_modules/gulp-util/lib/isNull.js new file mode 100644 index 000000000..403bb30e8 --- /dev/null +++ b/node_modules/gulp-util/lib/isNull.js @@ -0,0 +1,3 @@ +module.exports = function(v) { + return v === null; +};
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/isStream.js b/node_modules/gulp-util/lib/isStream.js new file mode 100644 index 000000000..9ce0929b0 --- /dev/null +++ b/node_modules/gulp-util/lib/isStream.js @@ -0,0 +1,5 @@ +var Stream = require('stream').Stream; + +module.exports = function(o) { + return !!o && o instanceof Stream; +};
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/linefeed.js b/node_modules/gulp-util/lib/linefeed.js new file mode 100644 index 000000000..5b0dfa4b1 --- /dev/null +++ b/node_modules/gulp-util/lib/linefeed.js @@ -0,0 +1 @@ +module.exports = '\n';
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/log.js b/node_modules/gulp-util/lib/log.js new file mode 100644 index 000000000..e33d15ed9 --- /dev/null +++ b/node_modules/gulp-util/lib/log.js @@ -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; +}; diff --git a/node_modules/gulp-util/lib/noop.js b/node_modules/gulp-util/lib/noop.js new file mode 100644 index 000000000..7862cb161 --- /dev/null +++ b/node_modules/gulp-util/lib/noop.js @@ -0,0 +1,5 @@ +var through = require('through2'); + +module.exports = function () { + return through.obj(); +}; diff --git a/node_modules/gulp-util/lib/replaceExtension.js b/node_modules/gulp-util/lib/replaceExtension.js new file mode 100644 index 000000000..3f76938e4 --- /dev/null +++ b/node_modules/gulp-util/lib/replaceExtension.js @@ -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); +};
\ No newline at end of file diff --git a/node_modules/gulp-util/lib/template.js b/node_modules/gulp-util/lib/template.js new file mode 100644 index 000000000..c467820f3 --- /dev/null +++ b/node_modules/gulp-util/lib/template.js @@ -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); +}; |