2018-07-10 07:49:23 +00:00
|
|
|
// Taken from views/index.js
|
|
|
|
|
|
|
|
// This creates a version of `require()` in the context of the current
|
|
|
|
// directory, so we iterate over its content, which is a map statically built by
|
|
|
|
// Webpack.
|
|
|
|
// Second argument says it's recursive, third makes sure we only load javascript.
|
2022-06-19 00:25:21 +00:00
|
|
|
const commands = require.context("./", true, /\.ts$/);
|
2018-07-10 07:49:23 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
export default commands.keys().reduce<Record<string, unknown>>((acc, path) => {
|
2018-07-10 07:49:23 +00:00
|
|
|
const command = path.substring(2, path.length - 3);
|
|
|
|
|
|
|
|
if (command === "index") {
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
2019-11-16 17:24:03 +00:00
|
|
|
acc[command] = commands(path).default;
|
2018-07-10 07:49:23 +00:00
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, {});
|