Files
2024-11-13 21:26:47 -05:00

30 lines
909 B
TypeScript
Executable File

#!/usr/bin/env bun
import { jjCliYargs } from "./jjCliYargs";
jjCliYargs(false)
const requiredProcessEnvs = {
JJ_SOURCE_DIR: process.env.JJ_SOURCE_DIR,
JJ_WORKSPACE_DIR: process.env.JJ_WORKSPACE_DIR
}
import { getJJConfigByKeyChain, getJjYamlObj, jjConfigsExp } from "./jjConfigUtils";
import _ from 'lodash';
import { dynamicStringHandler } from "./dynamicStringHandler";
const jjCommandConfig = getJJConfigByKeyChain(`commands['${process.env.JJ_CLI_ARG_1}']`)
if (!jjCommandConfig || _.isEmpty(jjCommandConfig)) {
console.error(`Command ${process.env.JJ_CLI_ARG_1} is not available`)
process.exit(0)
} else {
const scriptToRunPath = dynamicStringHandler(`${jjCommandConfig.scriptToRun.prePath}/${jjCommandConfig.scriptToRun.path}`, "", requiredProcessEnvs, false)
const scriptToRunFn = (await import(scriptToRunPath)).default
await scriptToRunFn()
process.exit(0)
}