Permalink
Browse files

Added glob plugin

  • Loading branch information...
tj committed Mar 21, 2012
1 parent 381a972 commit b66b65ce6f814239d3665e5763814bcfadf8b2f1
View
@@ -22,4 +22,5 @@ exports.version = '0.0.1';
*/
exports.ms = require('./plugins/ms');
+exports.glob = require('./plugins/glob');
exports.dimensions = require('./plugins/dimensions');
View
@@ -0,0 +1,11 @@
+
+/**
+ * Perform a glob, for example "glob: routes/*.js".
+ */
+
+module.exports = function(key, val){
+ var m = /^glob: *(.+)$/.exec(val);
+ if (!m) return;
+ return require('glob').sync(m[1]);
+}
+
View
@@ -4,11 +4,12 @@
, "description": "Extended JSON"
, "keywords": ["json", "config"]
, "author": "TJ Holowaychuk <tj@vision-media.ca>"
- , "dependencies": {}
+ , "dependencies": {
+ "glob": "*"
+ }
, "devDependencies": {
"mocha": "*",
- "should": "*",
- "glob": "*"
+ "should": "*"
}
, "main": "index"
, "engines": { "node": "*" }
View
No changes.
View
No changes.
View
No changes.
View
@@ -0,0 +1,23 @@
+
+var Parser = require('../')
+ , glob = Parser.glob;
+
+describe('glob', function(){
+ it('should perform a sync glob', function(){
+ glob('', 'glob: test/fixtures/*.js').should.eql(
+ ['test/fixtures/bar.js',
+ 'test/fixtures/baz.js',
+ 'test/fixtures/foo.js']
+ );
+
+ glob('', 'glob: test/fixtures/b*.js').should.eql(
+ ['test/fixtures/bar.js',
+ 'test/fixtures/baz.js']
+ );
+
+ glob('', 'glob: test/fixtures/{bar,foo}.js').should.eql(
+ ['test/fixtures/bar.js',
+ 'test/fixtures/foo.js']
+ );
+ })
+})

0 comments on commit b66b65c

Please sign in to comment.