// Modules import { promisify } from 'util'; import { exec } from "child_process"; // Debug import ModuleDebugBuilder from "../utilities/moduleDebugBuilder.js"; // Global Vars const log = new ModuleDebugBuilder("bot", "executeConsoleCommand"); const execCommand = promisify(exec); export async function executeAsyncConsoleCommand(consoleCommand) { // Check to see if the command is a real command // TODO needs to be improved const acceptableCommands = [ "arecord -L" ]; if (!acceptableCommands.includes(consoleCommand)) { log.WARN("Console command is not acceptable: ", consoleCommand); return undefined; } log.DEBUG("Running console command: ", consoleCommand); const tempOutput = await execCommand(consoleCommand); const output = tempOutput.stdout.trim(); log.DEBUG("Executed Console Command Response: ", output) // TODO add some error checking return output; }