2020-12-26 09:16:08 -08:00
|
|
|
/**
|
|
|
|
* Using some JavaScript trickery with require.context
|
|
|
|
* and default exports, we're basically rebuilding the
|
|
|
|
* Rails concept of "initializers" in JavaScript.
|
|
|
|
*
|
|
|
|
* Every file in this folder exports a default function
|
|
|
|
* which this index script is loading and executing, so
|
|
|
|
* we don't have to specify several single import
|
|
|
|
* statements and can dynamically extend this with as
|
|
|
|
* many initializers as we see fit.
|
|
|
|
*/
|
|
|
|
export default function initialize(): void {
|
|
|
|
const files = require.context('.', false, /\.ts$/);
|
|
|
|
|
|
|
|
files.keys().forEach((key) => {
|
|
|
|
if (key === './index.ts') return;
|
2021-02-27 11:44:38 -08:00
|
|
|
if (key.startsWith('./_')) return;
|
2020-12-26 09:16:08 -08:00
|
|
|
files(key).default();
|
|
|
|
});
|
|
|
|
}
|