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

https://github.com/doowb/gulp-routes

Add middleware to run for specified routes in your gulp pipeline.
https://github.com/doowb/gulp-routes

Last synced: about 2 months ago
JSON representation

Add middleware to run for specified routes in your gulp pipeline.

Awesome Lists containing this project

README

        

# gulp-routes [![NPM version](https://img.shields.io/npm/v/gulp-routes.svg?style=flat)](https://www.npmjs.com/package/gulp-routes) [![NPM monthly downloads](https://img.shields.io/npm/dm/gulp-routes.svg?style=flat)](https://npmjs.org/package/gulp-routes) [![NPM total downloads](https://img.shields.io/npm/dt/gulp-routes.svg?style=flat)](https://npmjs.org/package/gulp-routes) [![Linux Build Status](https://img.shields.io/travis/assemble/gulp-routes.svg?style=flat&label=Travis)](https://travis-ci.org/assemble/gulp-routes)

> Add middleware to run for specified routes in your gulp pipeline.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save gulp-routes
```

## Usage

### [routes](index.js#L43)

The main export is a function that takes an instance of [en-route](https://github.com/jonschlinkert/en-route) and returns a [gulp](http://gulpjs.com) plugin function.

**Params**

* `enRoute` **{Object}**: Instance of [en-route](https://github.com/jonschlinkert/en-route).
* `returns` **{Function}**

**Example**

```js
var routes = require('gulp-routes');
var Router = require('en-route').Router;
var router = new Router();

// define middleware
router.all(/\.hbs/, function (file, next) {
var str = file.contents.toString();
// do anything to `file` that can be done
// in a gulp plugin
file.contents = new Buffer(str);
next();
});

// pass the router to `gulp-routes`
var route = routes(router);

gulp.src('*.hbs')
.pipe(route())
.pipe(gulp.dest('_gh_pages/'));
```

### [route](index.js#L66)

Create a router stream to run middleware for the specified method.

**Params**

* `method` **{String}**: Method to run middleware.
* `returns` **{Stream}**: Returns a stream for piping files through.

**Example**

```js
gulp.src('*.hbs')
.pipe(route('before'))
.pipe(otherPlugin())
.pipe(route('after'))
.pipe(gulp.dest('dist/'));
```

## About

### Related projects

You might also be interested in these projects:

* [base-routes](https://www.npmjs.com/package/base-routes): Plugin for adding routes support to your `base` application. Requires templates support to work. | [homepage](https://github.com/node-base/base-routes "Plugin for adding routes support to your `base` application. Requires templates support to work.")
* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality node.js applications, using plugins like building blocks")
* [en-route](https://www.npmjs.com/package/en-route): Routing for static site generators, build systems and task runners, heavily based on express.js routes… [more](https://github.com/jonschlinkert/en-route) | [homepage](https://github.com/jonschlinkert/en-route "Routing for static site generators, build systems and task runners, heavily based on express.js routes but works with file objects. Used by Assemble, Verb, and Template.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Contributors

| **Commits** | **Contributor** |
| --- | --- |
| 6 | [jonschlinkert](https://github.com/jonschlinkert) |
| 5 | [doowb](https://github.com/doowb) |

### Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Brian Woodward**

* [github/doowb](https://github.com/doowb)
* [twitter/doowb](https://twitter.com/doowb)

### License

Copyright © 2017, [Brian Woodward](https://github.com/doowb).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 07, 2017._