aboutsummaryrefslogtreecommitdiff
path: root/node_modules/gulp-util/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-03 01:33:53 +0100
commitd1291f67551c58168af43698a359cb5ddfd266b0 (patch)
tree55a13ed29fe1915e3f42f1b1b7038dafa2e975a7 /node_modules/gulp-util/lib
parentd0a0695fb5d34996850723f7d4b1b59c3df909c2 (diff)
node_modules
Diffstat (limited to 'node_modules/gulp-util/lib')
-rw-r--r--node_modules/gulp-util/lib/File.js1
-rw-r--r--node_modules/gulp-util/lib/PluginError.js114
-rw-r--r--node_modules/gulp-util/lib/beep.js3
-rw-r--r--node_modules/gulp-util/lib/buffer.js2
-rw-r--r--node_modules/gulp-util/lib/colors.js1
-rw-r--r--node_modules/gulp-util/lib/date.js1
-rw-r--r--node_modules/gulp-util/lib/env.js2
-rw-r--r--node_modules/gulp-util/lib/isBuffer.js2
-rw-r--r--node_modules/gulp-util/lib/isNull.js2
-rw-r--r--node_modules/gulp-util/lib/isStream.js2
-rw-r--r--node_modules/gulp-util/lib/linefeed.js1
-rw-r--r--node_modules/gulp-util/lib/log.js16
-rw-r--r--node_modules/gulp-util/lib/replaceExtension.js9
-rw-r--r--node_modules/gulp-util/lib/template.js14
14 files changed, 56 insertions, 114 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
index d60159ab1..6640346ed 100644
--- a/node_modules/gulp-util/lib/PluginError.js
+++ b/node_modules/gulp-util/lib/PluginError.js
@@ -1,32 +1,22 @@
var util = require('util');
-var arrayDiffer = require('array-differ');
-var arrayUniq = require('array-uniq');
-var chalk = require('chalk');
-var objectAssign = require('object-assign');
-
-var nonEnumberableProperties = ['name', 'message', 'stack'];
-var propertiesNotToDisplay = nonEnumberableProperties.concat(['plugin', 'showStack', 'showProperties', '__safety', '_stack']);
+var colors = require('./colors');
// wow what a clusterfuck
var parseOptions = function(plugin, message, opt) {
- opt = opt || {};
+ if (!opt) opt = {};
if (typeof plugin === 'object') {
opt = plugin;
- } else {
- if (message instanceof Error) {
- opt.error = message;
- } else if (typeof message === 'object') {
- opt = message;
- } else {
- opt.message = message;
- }
+ } 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 objectAssign({
- showStack: false,
- showProperties: true
- }, opt);
+ return opt;
};
function PluginError(plugin, message, opt) {
@@ -35,19 +25,19 @@ function PluginError(plugin, message, opt) {
Error.call(this);
var options = parseOptions(plugin, message, opt);
- var self = this;
+
+ 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) {
- // These properties are not enumerable, so we have to add them explicitly.
- arrayUniq(Object.keys(options.error).concat(nonEnumberableProperties))
- .forEach(function(prop) {
- self[prop] = options.error[prop];
- });
+ properties.forEach(function(prop) {
+ if (prop in options.error) this[prop] = options.error[prop];
+ }, this);
}
- var properties = ['name', 'message', 'fileName', 'lineNumber', 'stack', 'showStack', 'showProperties', 'plugin'];
-
// options object can override
properties.forEach(function(prop) {
if (prop in options) this[prop] = options[prop];
@@ -56,18 +46,8 @@ function PluginError(plugin, message, opt) {
// defaults
if (!this.name) this.name = 'Error';
- if (!this.stack) {
- // Error.captureStackTrace appends a stack property which relies on the toString method of the object it is applied to.
- // Since we are using our own toString method which controls when to display the stack trace if we don't go through this
- // safety object, then we'll get stack overflow problems.
- var safety = {
- toString: function() {
- return this._messageWithDetails() + '\nStack:';
- }.bind(this)
- };
- Error.captureStackTrace(safety, arguments.callee || this.constructor);
- this.__safety = safety;
- }
+ // 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');
@@ -75,56 +55,10 @@ function PluginError(plugin, message, opt) {
util.inherits(PluginError, Error);
-PluginError.prototype._messageWithDetails = function() {
- var messageWithDetails = 'Message:\n ' + this.message;
- var details = this._messageDetails();
-
- if (details !== '') {
- messageWithDetails += '\n' + details;
- }
-
- return messageWithDetails;
-};
-
-PluginError.prototype._messageDetails = function() {
- if (!this.showProperties) {
- return '';
- }
-
- var properties = arrayDiffer(Object.keys(this), propertiesNotToDisplay);
-
- if (properties.length === 0) {
- return '';
- }
-
- var self = this;
- properties = properties.map(function stringifyProperty(prop) {
- return ' ' + prop + ': ' + self[prop];
- });
-
- return 'Details:\n' + properties.join('\n');
-};
-
PluginError.prototype.toString = function () {
- var sig = chalk.red(this.name) + ' in plugin \'' + chalk.cyan(this.plugin) + '\'';
- var detailsWithStack = function(stack) {
- return this._messageWithDetails() + '\nStack:\n' + stack;
- }.bind(this);
-
- var msg;
- if (this.showStack) {
- if (this.__safety) { // There is no wrapped error, use the stack captured in the PluginError ctor
- msg = this.__safety.stack;
- } else if (this._stack) {
- msg = detailsWithStack(this._stack);
- } else { // Stack from wrapped error
- msg = detailsWithStack(this.stack);
- }
- } else {
- msg = this._messageWithDetails();
- }
-
- return sig + '\n' + msg;
+ 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
index 26c940db1..4cb064aca 100644
--- a/node_modules/gulp-util/lib/buffer.js
+++ b/node_modules/gulp-util/lib/buffer.js
@@ -12,4 +12,4 @@ module.exports = function(fn) {
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/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
index ee17c0e30..ea1e03e4a 100644
--- a/node_modules/gulp-util/lib/env.js
+++ b/node_modules/gulp-util/lib/env.js
@@ -1,4 +1,4 @@
var parseArgs = require('minimist');
var argv = parseArgs(process.argv.slice(2));
-module.exports = argv;
+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
index 7c52f78c9..0e23782c4 100644
--- a/node_modules/gulp-util/lib/isBuffer.js
+++ b/node_modules/gulp-util/lib/isBuffer.js
@@ -4,4 +4,4 @@ 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
index 7f22c63ae..403bb30e8 100644
--- a/node_modules/gulp-util/lib/isNull.js
+++ b/node_modules/gulp-util/lib/isNull.js
@@ -1,3 +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
index 6b54e123b..9ce0929b0 100644
--- a/node_modules/gulp-util/lib/isStream.js
+++ b/node_modules/gulp-util/lib/isStream.js
@@ -2,4 +2,4 @@ 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
index bb843beef..e33d15ed9 100644
--- a/node_modules/gulp-util/lib/log.js
+++ b/node_modules/gulp-util/lib/log.js
@@ -1,14 +1,10 @@
-var hasGulplog = require('has-gulplog');
+var colors = require('./colors');
+var date = require('./date');
module.exports = function(){
- if(hasGulplog()){
- // specifically deferring loading here to keep from registering it globally
- var gulplog = require('gulplog');
- gulplog.info.apply(gulplog, arguments);
- } else {
- // specifically defering loading because it might not be used
- var fancylog = require('fancy-log');
- fancylog.apply(null, arguments);
- }
+ 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/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
index eef3bb376..c467820f3 100644
--- a/node_modules/gulp-util/lib/template.js
+++ b/node_modules/gulp-util/lib/template.js
@@ -1,21 +1,17 @@
var template = require('lodash.template');
-var reEscape = require('lodash._reescape');
-var reEvaluate = require('lodash._reevaluate');
var reInterpolate = require('lodash._reinterpolate');
var forcedSettings = {
- escape: reEscape,
- evaluate: reEvaluate,
+ escape: /<%-([\s\S]+?)%>/g,
+ evaluate: /<%([\s\S]+?)%>/g,
interpolate: reInterpolate
};
-module.exports = function(tmpl, data) {
- var fn = template(tmpl, forcedSettings);
+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');
- }
+ 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);
};