├── .gitignore ├── .editorconfig ├── package.json ├── index.js └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DocumentRevisions-V100 2 | .DS_Store 3 | .fseventsd 4 | .Spotlight-V100 5 | .svn 6 | .TemporaryItems 7 | .Trash 8 | .Trashes 9 | desktop.ini 10 | node_modules 11 | Thumbs.db 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-using", 3 | "version": "0.1.1", 4 | "description": "Lists all files used", 5 | "main": "index.js", 6 | "repository": "jeromedecoster/gulp-using", 7 | "files": [ 8 | "index.js" 9 | ], 10 | "keywords": [ 11 | "gulpplugin", 12 | "log", 13 | "file", 14 | "using" 15 | ], 16 | "engines": { 17 | "node": ">=0.10.0" 18 | }, 19 | "dependencies": { 20 | "chalk": "~0.4.0", 21 | "map-stream": "~0.1.0", 22 | "pretty-bytes": "^3.0.1" 23 | }, 24 | "author": "jeromedecoster", 25 | "license": "MIT" 26 | } 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | const bytes = require('pretty-bytes') 3 | const map = require('map-stream') 4 | const chalk = require('chalk') 5 | 6 | module.exports = function(options) { 7 | options = options || {} 8 | 9 | var paths = 'path relative'.split(' ') 10 | var colors = 'black blue cyan gray green red white yellow'.split(' ') 11 | 12 | options.prefix = options.prefix || 'Using' 13 | options.path = paths.indexOf(options.path) != -1 ? options.path : 'cwd' 14 | options.color = colors.indexOf(options.color) != -1 ? options.color : 'magenta' 15 | options.filesize = typeof options.filesize !== 'undefined' ? options.filesize : false 16 | 17 | return map(function(file, cb) { 18 | 19 | var f = file.path.replace(file.cwd, '.') 20 | if (options.path == 'relative') { f = file.relative } 21 | else if (options.path == 'path') { f = file.path } 22 | 23 | if (options.filesize && file.contents) { 24 | f += (' - ' + bytes(file.contents.length)) 25 | } 26 | 27 | var time = '['+chalk.gray(new Date().toTimeString().slice(0, 8))+']' 28 | 29 | console.log(time, options.prefix, chalk[options.color](f)) 30 | 31 | cb(null, file) 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # gulp-using 2 | 3 | Gulp filter. Lists all files used. Helps you to verify what your patterns catch 4 | 5 | ## Install 6 | 7 | ``` 8 | npm install --save-dev gulp-using 9 | ``` 10 | 11 | ## Example 12 | 13 | After some complex `src` patterns, and some added filter plugins, it helps you to list all files catched 14 | 15 | ```js 16 | const using = require('gulp-using') 17 | 18 | var jsfiles = ['./src/js/**/*.js', '!./src/js/vendor/**'] 19 | 20 | gulp.task('default', function() { 21 | gulp.watch(jsfiles, function() { 22 | gulp.src(jsfiles) 23 | // action or filter... 24 | .pipe(using()) 25 | // ... 26 | }) 27 | }) 28 | ``` 29 | 30 | Output: 31 | 32 | ``` 33 | [12:18:43] Running 'default'... 34 | [12:18:43] Finished 'default' in 14 ms 35 | [12:18:43] Using ./src/js/index.js 36 | [12:18:43] Using ./src/js/multiply.js 37 | [12:18:43] Using ./src/js/square.js 38 | ``` 39 | 40 | ## Options 41 | 42 | #### path 43 | 44 | How the file path is displayed 45 | 46 | * Type: `String` 47 | * Default: `cwd` 48 | * Values: `cwd`, `path`, `relative` 49 | 50 | #### color 51 | 52 | How the file path is colored 53 | 54 | * Type: `String` 55 | * Default: `magenta` 56 | * Values: `black`, `blue`, `cyan`, `gray`, `green`, `magenta`, `red`, `white`, `yellow` 57 | 58 | #### prefix 59 | 60 | Message shown before the file path 61 | 62 | * Type: `String` 63 | * Default: `Using` 64 | 65 | #### filesize 66 | 67 | Filesize shown after the file path 68 | 69 | * Type: `Boolean` 70 | * Default: `false` 71 | 72 | 73 | ```js 74 | // ... 75 | .pipe(using({prefix:'Using file', path:'relative', color:'blue', filesize:true})) 76 | ``` 77 | 78 | Output: 79 | 80 | ``` 81 | [12:18:43] Running 'default'... 82 | [12:18:43] Finished 'default' in 14 ms 83 | [12:18:43] Using file index.js 84 | [12:18:43] Using file multiply.js 85 | [12:18:43] Using file square.js 86 | ``` 87 | --------------------------------------------------------------------------------