(command: string, ...args: CommandArg[])
| 40 | |
| 41 | type CommandArg = [string, string | string[] | number | boolean]; |
| 42 | const execCommand = (command: string, ...args: CommandArg[]) => { |
| 43 | const quote = (val: string) => `"${val}"`; |
| 44 | const formattedArgs = args |
| 45 | .map(([c, a]) => { |
| 46 | // if args is array then quote each elem and separate them with space |
| 47 | if (Array.isArray(a)) return `${c} ${a.map(quote).join(' ')}`; |
| 48 | // otherwise just quote each elem and separate them with space |
| 49 | else return `${c} ${quote(String(a))}`; |
| 50 | }) |
| 51 | .join(' '); |
| 52 | const formattedCommand = `${command} ${formattedArgs}`; |
| 53 | if (DEBUG_COMMANDS) logger.log(`Executing command: ${formattedCommand}`); |
| 54 | |
| 55 | const goExecSync = goSync(() => execSync(`node ${CLI_EXECUTABLE} ${formattedCommand}`).toString().trim()); |
| 56 | if (!goExecSync.success) { |
| 57 | // rethrow the output of the CLI |
| 58 | throw new Error((goExecSync.error as any).reason.stdout.toString().trim()); |
| 59 | } |
| 60 | return goExecSync.data; |
| 61 | }; |
| 62 | |
| 63 | const deriveSponsorWallet = (airnodeMnemonic: string, sponsorAddress: string): ethers.Wallet => { |
| 64 | return ethers.Wallet.fromMnemonic( |
no test coverage detected