mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 18:32:52 +02:00
fix(core): normalize input for poll option (#8342)
Fixes https://github.com/facebook/docusaurus/issues/8306
This commit is contained in:
parent
5d2dd9b6b4
commit
029417154c
1 changed files with 18 additions and 0 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue