From 06e89c9b47bca5f9aa927219d2475a36d9201ce4 Mon Sep 17 00:00:00 2001 From: Jaakko Holster Date: Fri, 27 Oct 2017 16:30:51 +0300 Subject: [PATCH 1/3] Add 'include' and 'exclude' options to limit which paths are brfs'd Both options take a minimatch pattern in a string, which is matched against absolute path of the file being transformed. Example: browserify -g [ brfs --exclude '**/node_modules/problematic/*' ] ... --- index.js | 3 +++ package.json | 1 + readme.markdown | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) 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..a72ec44 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "brfs": "bin/cmd.js" }, "dependencies": { + "minimatch": "^3.0.4", "quote-stream": "^1.0.1", "resolve": "^1.1.5", "static-module": "^1.1.0", diff --git a/readme.markdown b/readme.markdown index f98a448..36d6705 100644 --- a/readme.markdown +++ b/readme.markdown @@ -125,6 +125,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 +142,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. From 20b35c29c6e43842a77a03f967d8b7ab85b0916a Mon Sep 17 00:00:00 2001 From: Jaakko Holster Date: Fri, 27 Oct 2017 16:31:33 +0300 Subject: [PATCH 2/3] Add .editorconfig file (http://editorconfig.org) This helps contributors to keep the source format consistent, e.g. preserving the whitespace indentation in empty lines. --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .editorconfig 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 From c07427fe1e14b583ffc7defee5d79cb0cd7bc691 Mon Sep 17 00:00:00 2001 From: Jaakko Holster Date: Mon, 30 Oct 2017 09:12:50 +0200 Subject: [PATCH 3/3] Publish in npm as brfs2 until pull request accepted --- package.json | 13 ++++++------- readme.markdown | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a72ec44..df76df6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "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" @@ -24,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", @@ -39,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 36d6705..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