UNPKG

968 BJavaScriptView Raw
1'use strict';
2var path = require('path');
3var gutil = require('gulp-util');
4var through = require('through');
5var tildify = require('tildify');
6var dateTime = require('date-time');
7var prop = gutil.colors.blue;
8var header = gutil.colors.underline;
9
10module.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};