This cleans up the work from #1582, clarifying concerns, removing a bit of duplication, and renaming for clarity.
25 lines
551 B
JavaScript
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,
|
|
};
|