UNPKG

@tech-bureau/mijin-catapult-tools

Version:

This tool is for easy operation of mijin Catapult(v.2)

18 lines (15 loc) 518 B
import { execSync, spawnSync, SpawnSyncOptionsWithStringEncoding } from 'child_process' export default class CmdServices { constructor() {} static exec(cmd: string, cmdArgs: string[]) { const options: SpawnSyncOptionsWithStringEncoding = { encoding: 'utf8', timeout: 30, } const { error, stderr, stdout } = spawnSync(cmd, cmdArgs, options) if (error) throw error const stderrStr = stderr.toString() if (stderrStr) throw new Error(stderrStr) return stdout.toString() } }