| 11 | let slugDir: string; |
| 12 | |
| 13 | function runLog(input: string, opts: { expectFail?: boolean } = {}): { stdout: string; exitCode: number } { |
| 14 | const execOpts: ExecSyncOptionsWithStringEncoding = { |
| 15 | cwd: ROOT, |
| 16 | env: { ...process.env, GSTACK_HOME: tmpDir }, |
| 17 | encoding: 'utf-8', |
| 18 | timeout: 15000, |
| 19 | }; |
| 20 | try { |
| 21 | const stdout = execSync(`${BIN}/gstack-timeline-log '${input.replace(/'/g, "'\\''")}'`, execOpts).trim(); |
| 22 | return { stdout, exitCode: 0 }; |
| 23 | } catch (e: any) { |
| 24 | if (opts.expectFail) { |
| 25 | return { stdout: e.stderr?.toString() || '', exitCode: e.status || 1 }; |
| 26 | } |
| 27 | throw e; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | function runRead(args: string = ''): string { |
| 32 | const execOpts: ExecSyncOptionsWithStringEncoding = { |