Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-291.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `pluk watch --capture=<ms>` now rejects fractional intervals such as `--capture=1.5`, accepting only positive integers as documented (#291).
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function cmdWatch(args: string[]): void {
}
if (capture !== undefined && capture !== 'true') {
captureIntervalMs = Number(capture);
if (!Number.isFinite(captureIntervalMs) || captureIntervalMs <= 0) {
if (!Number.isInteger(captureIntervalMs) || captureIntervalMs <= 0) {
console.error(`${paintStderr(ANSI_RED, 'Error:')} --capture expects a positive integer number of milliseconds`);
process.exit(2);
}
Expand Down
2 changes: 1 addition & 1 deletion test/cli-watch-guard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test('run-tests.mjs propagates the child suite exit status', () => {

// --- watch: invalid --capture interval is rejected -------------------------------

for (const bad of ['0', '-5', 'abc', '']) {
for (const bad of ['0', '-5', 'abc', '', '1.5']) {
test(`watch --capture=${bad} exits 2 with a usage error`, () => {
const { code, stderr } = run(CLI, ['watch', 'x', `--capture=${bad}`]);
assert.equal(code, 2);
Expand Down
Loading