mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-22 04:58:00 +01:00
8bc3f7fe36
This code serves as an application framework of sorts and is totally not stolen from some of my other projects.
24 lines
No EOL
746 B
TypeScript
24 lines
No EOL
746 B
TypeScript
"use strict";
|
|
|
|
import env from "./config-handlers/env";
|
|
import file from "./config-handlers/file";
|
|
import secret from "./config-handlers/secret";
|
|
|
|
const replacers = {
|
|
env,
|
|
file,
|
|
secret
|
|
};
|
|
|
|
function replaceArguments(commanderValues: { [key: string]: any }): void {
|
|
Object.keys(commanderValues).forEach(key => {
|
|
if (key.startsWith("_") || !commanderValues[key] || typeof commanderValues[key] !== "string") return;
|
|
Object.entries(replacers).forEach(([replaceKey, replacer]) => {
|
|
const value = commanderValues[key];
|
|
if (value.match(new RegExp(`^${replaceKey}:`, "i")))
|
|
commanderValues[key] = replacer(value.split(":")[1]);
|
|
});
|
|
});
|
|
}
|
|
|
|
export default replaceArguments; |