| 79 | }); |
| 80 | |
| 81 | function run(command, args, cwd, extraEnv = {}) { |
| 82 | const started = Date.now(); |
| 83 | return new Promise((done) => { |
| 84 | const child = spawn(command, args, { |
| 85 | cwd, |
| 86 | env: { ...childEnv(), ...extraEnv }, |
| 87 | stdio: ['ignore', 'pipe', 'pipe'], |
| 88 | }); |
| 89 | let out = ''; |
| 90 | child.stdout.on('data', (chunk) => { |
| 91 | out += chunk.toString(); |
| 92 | }); |
| 93 | child.stderr.on('data', (chunk) => { |
| 94 | out += chunk.toString(); |
| 95 | }); |
| 96 | child.on('error', (error) => done({ code: 127, out: out + error.message, ms: Date.now() - started })); |
| 97 | child.on('close', (code) => done({ code: code ?? 1, out, ms: Date.now() - started })); |
| 98 | }); |
| 99 | } |
| 100 | |
| 101 | /** Der letzte Rest einer Ausgabe, so viel wie in einen Bericht gehoert. */ |
| 102 | const tail = (text, lines = 12) => |