zx
zx copied to clipboard
Spinner crashes CI build because `process.stdout.columns === 0`
Expected Behavior
spinner
shouldn't throw errors
Actual Behavior
/tmp/gitlab/builds/xrEFg3V1/0/pool/frontend/.yarn/cache/zx-npm-7.2.1-dc2fa8860f-372e9ef8fc.zip/node_modules/zx/build/goods.js:167
process.stderr.write(' '.repeat(process.stdout.columns - 1) + '\r');
^
RangeError: Invalid count value: -1
at String.repeat (<anonymous>)
at <anonymous> (/tmp/gitlab/builds/xrEFg3V1/0/pool/frontend/.yarn/cache/zx-npm-7.2.1-dc2fa8860f-372e9ef8fc.zip/node_modules/zx/build/goods.js:167:38)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.8.1
the offending code:
finally {
clearInterval(id);
process.stderr.write(' '.repeat(process.stdout.columns - 1) + '\r');
}
Apparently, the process.stdout.columns
is 0
when running in GitLab CI through the NIX script runner & the script
utility.
I don't know which part of the stack causes the columns
value to be 0, but I suppose script
would be the best bet.
I'm using this to force NIX to preserve colors, of my build scripts.
To fix this, I'D propose to Math.max
the computed repetition value to 0
at https://github.com/google/zx/blob/main/src/goods.ts#L201
Specifications
- Version: 7.2.1
- Platform: Linux