From b5bd9f57b6567e18ec0197ddb92119a8b3f958b4 Mon Sep 17 00:00:00 2001 From: Josh Johnston Date: Wed, 5 Aug 2015 16:39:35 +1000 Subject: [PATCH] add ignore option --- index.js | 5 ++++- readme.markdown | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9635d7a..7f19e24 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,10 @@ var path = require('path'); var resolve = require('resolve'); module.exports = function (file, opts) { - if (/\.json$/.test(file)) return through(); + var ignore = opts.ignore || opts.i || /\.json$/; + if (typeof ignore === 'string') { ignore = new RegExp(ignore); } + + if (ignore.test(file)) return through(); function resolver (p) { return resolve.sync(p, { basedir: path.dirname(file) }); diff --git a/readme.markdown b/readme.markdown index 8791f0d..678ebb1 100644 --- a/readme.markdown +++ b/readme.markdown @@ -125,6 +125,10 @@ Optionally, you can set which `opts.vars` will be used in the [static argument evaluation](https://npmjs.org/package/static-eval) in addition to `__dirname` and `__filename`. +`opts.ignore` can be used to skip certain files. It expects a `RegExp` but +if a string is given it will convert. If omitted the default of `/\.json$/` +is used. + # events ## tr.on('file', function (file) {})