ddl-manager
Version:
store postgres procedures and triggers in files
41 lines (33 loc) • 956 B
JavaScript
;
const parseArgs = require("minimist");
const args = parseArgs(
process.argv[0] == "ddl-manager" ?
process.argv.slice(1) :
process.argv.slice(2)
);
const commands = {
undefined: require("./commands/undefined"),
help: require("./commands/help"),
build: require("./commands/build"),
watch: require("./commands/watch"),
dump: require("./commands/dump"),
"refresh-cache": require("./commands/refresh-cache")
};
// $ ddl-manager build
// commandName will "build"
const commandName = args._[0];
const command = commands[ commandName ] || commands.undefined;
// run command
(async function() {
try {
if ( "help" in args && command != commands.undefined ) {
commands.help(args, commandName);
} else {
await command(args);
}
} catch(err) {
console.error("Error: " + err.message);
process.exit(1);
}
})();