requirejs-glob
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -13,5 +13,6 @@ /** | ||
var fs = require('fs'); | ||
var url = require('url'); | ||
/** | ||
* Express middleware web service called by the glob! plugin in the browser | ||
* Connect / Express middleware web service called by the glob! plugin in the browser | ||
* @return {Array} matching file paths for RequireJS to load | ||
@@ -22,3 +23,5 @@ */ | ||
if (req.url.match(/^\/requirejs-glob/)){ | ||
res.send(module.exports.match(req.query.glob, req.query.from)); | ||
var query = url.parse(req.url, true).query; | ||
var json = JSON.stringify(module.exports.match(query.glob, query.from)); | ||
res.end(json); | ||
} | ||
@@ -56,2 +59,2 @@ else next(); | ||
return files; | ||
}; | ||
}; |
{ | ||
"name": "requirejs-glob", | ||
"main": "lib/requirejs-glob", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "glob-whatev": "~0.1.8" |
@@ -23,3 +23,3 @@ #requirejs-glob | ||
This piece is currently available as an [Express](http://expressjs.com/guide.html) middleware. | ||
This piece is currently available as a [Connect](http://www.senchalabs.org/connect/) and [Express](http://expressjs.com/guide.html) compatible middleware. | ||
@@ -70,2 +70,35 @@ ##Getting Started | ||
##Grunt integration | ||
The middleware can also be used as part of a [Grunt][] build, where the web server | ||
is created with the [grunt-contrib-connect][] task. To do this, the grunt | ||
task must be configured with custom middleware. | ||
For a registered task named `connect:server`, where compiled files are placed | ||
in the `generated` directory, use the [middleware][] configuration option to | ||
load support for the requirejs glob middleware. | ||
```javascript | ||
connect: { | ||
server: { | ||
options: { | ||
base: "generated", | ||
middleware: function(connect, options) { | ||
// Return array of whatever middlewares you want | ||
return [ | ||
require('requirejs-glob')(), | ||
// standard middleware for static files and dir browsing | ||
connect.static(options.base), | ||
connect.directory(options.base) | ||
]; | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
[Grunt]: http://gruntjs.com/ | ||
[grunt-contrib-connect]: https://github.com/gruntjs/grunt-contrib-connect | ||
[middleware]: https://github.com/gruntjs/grunt-contrib-connect#middleware | ||
##License | ||
@@ -77,2 +110,2 @@ MIT | ||
[] tests | ||
[] examples | ||
[] examples |
7673
119
109