1 | 'use strict';
|
2 | var path = require('path');
|
3 | var gutil = require('gulp-util');
|
4 | var through = require('through');
|
5 | var tildify = require('tildify');
|
6 | var dateTime = require('date-time');
|
7 | var prop = gutil.colors.blue;
|
8 | var header = gutil.colors.underline;
|
9 |
|
10 | module.exports = function (options) {
|
11 | return through(function (file) {
|
12 | if (file.isStream()) {
|
13 | return this.emit('error', new gutil.PluginError('gulp-debug', 'Streaming not supported'));
|
14 | }
|
15 |
|
16 | var fileObj =
|
17 | (file.cwd ? 'cwd: ' + prop(tildify(file.cwd)) : '') +
|
18 | (file.base ? '\nbase: ' + prop(tildify(file.base)) : '') +
|
19 | (file.path ? '\npath: ' + prop(tildify(file.path)) : '') +
|
20 | (file.stat ? '\nstat: ' + prop(file.stat) : '') +
|
21 | (file.contents ? '\ncontents: ' + prop(file.contents.toString('utf8', 0, 40).trim() + '...\n') : '');
|
22 |
|
23 | gutil.log(
|
24 | 'gulp-debug: ' + gutil.colors.gray('(' + dateTime() + ')') + '\n\n' +
|
25 | header('File\n') + fileObj
|
26 | );
|
27 |
|
28 | this.queue(file);
|
29 | });
|
30 | };
|