Files
shields/services/index.js
Paul Melnikow f2efd751b5 Minor refactor of examples preparation (#1632)
This cleans up the work from #1582, clarifying concerns, removing a bit of duplication, and renaming for clarity.
2018-04-02 07:03:52 -05:00

25 lines
551 B
JavaScript

'use strict';
const glob = require('glob');
// Match modules with the same name as their containing directory.
// e.g. services/appveyor/appveyor.js
const serviceRegex = /\/services\/(.*)\/\1\.js$/;
function loadServiceClasses() {
// New-style services
return glob.sync(`${__dirname}/**/*.js`)
.filter(path => serviceRegex.test(path))
.map(path => require(path))
}
function loadTesters() {
return glob.sync(`${__dirname}/**/*.tester.js`)
.map(path => require(path));
}
module.exports = {
loadServiceClasses,
loadTesters,
};