MCPcopy Create free account
hub / github.com/ZingerLittleBee/ServerBee / runShellCommand

Function runShellCommand

scripts/make-menu.ts:629–649  ·  view source on GitHub ↗
(command: CommandDefinition)

Source from the content-addressed store, hash-verified

627}
628
629const runShellCommand = async (command: CommandDefinition): Promise<number> => {
630 await recordRecentCommand(HISTORY_PATH, command.key, Date.now())
631
632 return new Promise<number>((resolve, reject) => {
633 const childProcess = spawn(command.command, {
634 cwd: ROOT_DIRECTORY,
635 shell: true,
636 stdio: 'inherit'
637 })
638
639 childProcess.on('error', reject)
640 childProcess.on('exit', (code, signal) => {
641 if (signal) {
642 resolve(1)
643 return
644 }
645
646 resolve(code ?? 0)
647 })
648 })
649}
650
651const printRecentCommands = async (): Promise<void> => {
652 const recentCommands = await readRecentCommands()

Callers 1

mainFunction · 0.85

Calls 2

recordRecentCommandFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected