Skip to content

Commit

Permalink
fix(core): normalize input for poll option (#8342)
Browse files Browse the repository at this point in the history
Fixes #8306
  • Loading branch information
mhnaeem authored and slorber committed Jan 26, 2023
1 parent 5d2dd9b commit 0294171
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/docusaurus/bin/docusaurus.mjs
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

0 comments on commit 0294171

Please sign in to comment.