Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

Commit

Permalink
change lib struc - mincer required, options and babel optional
Browse files Browse the repository at this point in the history
improve readme with doc
  • Loading branch information
naxmefy committed Jun 17, 2016
1 parent ffcd88d commit 284a8ba
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,51 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/4b85c1c632514d10a85397a5eeb06c8d)](https://www.codacy.com/app/naxmefy/mincer-babel-engine?utm_source=github.com&utm_medium=referral&utm_content=damncreative/mincer-babel-engine&utm_campaign=Badge_Coverage)

[![NPM](https://nodei.co/npm/mincer-babel-engine.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/mincer-babel-engine/)

## installation

```
$ npm install mincer-babel-engine
```

## usage

```JavaScript
var babelEngine = require('mincer-babel-engine');
var Mincer = require('mincer');

babelEngine(Mincer);
```

### Lib Function

**babelEngine(mincer [,options] [,babel-core])**

```JavaScript
var babelEngine = require('mincer-babel-engine');
var mincer = require('mincer');
var babelCore = require('babel-core');

// examples
babelEngine(mincer); // with mincer
babelEngine(mincer, {}); // with mincer and options
babelEngine(mincer, {}, babel); // with mincer, options and own babel-core
```

## options

* ``` extensions ``` Supported extensions by this engine. (``` Array ``` of Strings. Default: ``` ['.es6'] ```)
* ``` babel ``` Babel options to use for transform. (``` Object ```. Default: ``` {} ```)

## configure

**Mincer.BabelEngine.configure(options)**

```JavaScript
// ...
Mincer.BabelEngine.configure({
preset: ['es2015']
});
```

Hint: The object in configure is passed to ``` babel ``` property of engine options.
8 changes: 1 addition & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ var defaultOptions = {
babel: {}
};

module.exports = function (options, mincer, babel) {
module.exports = function (mincer, options, babel) {
options = _.merge({}, defaultOptions, options);

if (mincer == null) {
mincer = require('mincer');
}

debug('setup engine');
debug('options %j', options);

Expand Down Expand Up @@ -59,7 +55,5 @@ module.exports = function (options, mincer, babel) {
mincer.registerEngine(ext, mincer.BabelEngine);
});

mincer.registerEngine('.es6', mincer.BabelEngine);

Object.defineProperty(mincer.BabelEngine, 'defaultMimeType', {value: 'application/javascript'});
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"dependencies": {
"babel-core": "^6.9.1",
"debug": "^2.2.0",
"lodash": "^4.13.1",
"mincer": "^1.4.1"
"lodash": "^4.13.1"
},
"devDependencies": {
"babel-preset-es2015": "^6.9.0",
"mincer": "^1.4.1",
"mocha": "^2.5.3",
"should": "^9.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions test/helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

var babelEngine = require('..');
var mincer = require('mincer');
babelEngine({
babelEngine(mincer, {
extensions: ['.es6', '.js']
}, mincer);
});

before(function() {
this.Mincer = mincer;
Expand Down
7 changes: 0 additions & 7 deletions test/local-mincer.spec.js

This file was deleted.

0 comments on commit 284a8ba

Please sign in to comment.