diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..96f9283 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*.js] +trim_trailing_whitespace = false diff --git a/index.js b/index.js index 03669cc..b436247 100644 --- a/index.js +++ b/index.js @@ -4,9 +4,12 @@ var through = require('through2'); var fs = require('fs'); var path = require('path'); var resolve = require('resolve'); +var minimatch = require('minimatch'); module.exports = function (file, opts) { if (/\.json$/.test(file)) return through(); + if (opts.exclude && minimatch(file, opts.exclude)) return through(); + if (opts.include && ! minimatch(file, opts.include)) return through(); function resolver (p) { return resolve.sync(p, { basedir: path.dirname(file) }); diff --git a/package.json b/package.json index 4ce9ef1..df76df6 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { - "name": "brfs", + "name": "brfs2", "version": "1.4.3", - "description": "browserify fs.readFileSync() static asset inliner", + "description": "Browserify fs.readFileSync() static asset inliner (fork)", "main": "index.js", "bin": { "brfs": "bin/cmd.js" }, "dependencies": { + "minimatch": "^3.0.4", "quote-stream": "^1.0.1", "resolve": "^1.1.5", "static-module": "^1.1.0", @@ -23,9 +24,9 @@ }, "repository": { "type": "git", - "url": "git://github.com/substack/brfs.git" + "url": "git://github.com/jholster/brfs.git" }, - "homepage": "https://github.com/substack/brfs", + "homepage": "https://github.com/jholster/brfs", "keywords": [ "browserify", "browserify-transform", @@ -38,9 +39,8 @@ "base64" ], "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" + "name": "Jaakko Holster", + "email": "holster@iki.fi" }, "license": "MIT" } diff --git a/readme.markdown b/readme.markdown index f98a448..05dfc7c 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,3 +1,7 @@ +### This repository contains a fork of [brfs](https://github.com/browserify/brfs) published as [brfs2 in npm] (https://www.npmjs.com/package/brfs2) until [this pull request will be merged](https://github.com/browserify/brfs/pull/82). + +***** + # brfs fs.readFileSync() and fs.readFile() static asset browserify transform @@ -125,6 +129,8 @@ 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`. +Also, it's possible to define [minimatch](https://github.com/isaacs/minimatch) patterns against absolute paths in `opts.include` and `opts.exclude` to transform only a subset of source files. + # events ## tr.on('file', function (file) {}) @@ -140,13 +146,13 @@ A tiny command-line program ships with this module to make debugging easier. usage: brfs file - + Inline `fs.readFileSync()` calls from `file`, printing the transformed file contents to stdout. brfs brfs - - + Inline `fs.readFileSync()` calls from stdin, printing the transformed file contents to stdout.