Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): normalize input for poll option #8342

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Changes from all commits
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
18 changes: 18 additions & 0 deletions packages/docusaurus/bin/docusaurus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ cli
)
.action(deploy);

/**
* @param {string | undefined} value
* @returns {boolean | number}
*/
function normalizePollValue(value) {
if (value === undefined || value === '') {
return false;
}

const parsedIntValue = Number.parseInt(value, 10);
if (!Number.isNaN(parsedIntValue)) {
return parsedIntValue;
}

return value === 'true';
}

cli
.command('start [siteDir]')
.description('Start the development server.')
Expand All @@ -122,6 +139,7 @@ cli
.option(
'--poll [interval]',
'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds',
normalizePollValue,
)
.option(
'--no-minify',
Expand Down