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

Fixes https://github.com/facebook/docusaurus/issues/8306
This commit is contained in:
Muhammad Hammad 2022-11-17 05:22:12 -05:00 committed by sebastienlorber
parent 5d2dd9b6b4
commit 029417154c

View file

@ -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.')
@ -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',