mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
19 lines
574 B
TypeScript
19 lines
574 B
TypeScript
// 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.
|
|
const commands = require.context("./", true, /\.ts$/);
|
|
|
|
export default commands.keys().reduce<Record<string, unknown>>((acc, path) => {
|
|
const command = path.substring(2, path.length - 3);
|
|
|
|
if (command === "index") {
|
|
return acc;
|
|
}
|
|
|
|
acc[command] = commands(path).default;
|
|
|
|
return acc;
|
|
}, {});
|