Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thlorenz/transfigurify

Configure which browserify transforms get applied to your package via an environment variable.
https://github.com/thlorenz/transfigurify

Last synced: 15 days ago
JSON representation

Configure which browserify transforms get applied to your package via an environment variable.

Awesome Lists containing this project

README

        

# transfigurify [![build status](https://secure.travis-ci.org/thlorenz/transfigurify.png)](http://travis-ci.org/thlorenz/transfigurify)

Configure which [browserify](https://github.com/substack/node-browserify) transforms get applied to your package via an environment variable.

#### package.json

```json
{
"browserify": {
"transform": [
"hbsfy",
"transfigurify"
]
},
"transfigurify": {
"test": [
"brfs"
]
},
"dependencies": {
"brfs": "0.0.9",
"hbsfy": "~0.1.3",
"transfigurify": "~0.1.0"
}
}
```

In this configuration the `hbsfy` transform runs always, but the `brfs` transform is applied only if
`TRANSFIGURIFY_ENV=test`, i.e:

TRANSFIGURIFY_ENV=test browserify main.js > bundle.js

## Examples

Please review and try this [full example](https://github.com/thlorenz/transfigurify/tree/master/example) to get a better
understanding of how transfigurify works.

Reading the [tests](https://github.com/thlorenz/transfigurify/tree/master/test) is also benefitial to that end.

## Installation

npm install transfigurify

## API









transfigurify::env





The env variable which is used by transfigurify to determine which transforms config in the package.json to use
in order to apply transforms.


You need to set this or provide it via the TRANSFIGURIFY_ENV environment variable.


// setting from javascript

transfigurify.env = 'test';

# setting from command line

TRANSFIGURIFY_ENV=test browserify -t transfigurify ...



Source:








transfigurify(file) → {TransformStream}





browserify transform which applies a set of browserify transforms that are configured inside package.json.
Multiple sets can be configured and a matching one selected depending on the TRANSFIGURIFY_ENV environment variable.


This variable can also be set directly via transfigurify.env='x'.


If no matching configuration is found or the environment variable wasn't set a through stream is returned which
means that the file will not be transformed by transfigurify.



Parameters:

Name
Type
Description

file

string

file whose content is to be transformed


Source:



Returns:


transform that is composed of the transforms that were configured for the environment (if any)





Type


TransformStream



*generated with [docme](https://github.com/thlorenz/docme)*

## License

MIT