Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'include' and 'exclude' options for more fine-tuned control over brfs'd files #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*.js]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) });
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -38,9 +39,8 @@
"base64"
],
"author": {
"name": "James Halliday",
"email": "[email protected]",
"url": "http://substack.net"
"name": "Jaakko Holster",
"email": "[email protected]"
},
"license": "MIT"
}
10 changes: 8 additions & 2 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {})
Expand All @@ -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.

Expand Down