allow plugins to specify frontend test specs

This commit is contained in:
John McLear 2013-02-03 00:14:17 +00:00
parent 9c0f881811
commit 594d272334
1 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,17 @@ var path = require("path")
exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/tests/frontend/specs_list.js', function(req, res){
fs.readdir('tests/frontend/specs', function(err, files){
fs.readdir('node_modules', function(err, plugins){ // installed plugins
plugins.forEach(function(plugin){ // for each one
if(fs.existsSync("node_modules/"+plugin+"/tests/frontend/specs")){ // If the folder exists
fs.readdir("node_modules/"+plugin+"/tests/frontend/specs/", function(err, pluginFiles){
files.push(pluginFiles);
});
}
});
});
if(err){ return res.send(500); }
res.send("var specs_list = " + JSON.stringify(files.sort()) + ";\n");
@ -44,4 +55,4 @@ exports.expressCreateServer = function (hook_name, args, cb) {
args.app.get('/tests/frontend', function (req, res) {
res.redirect('/tests/frontend/');
});
}
}