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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/docusaurus/bin/docusaurus.mjs
Expand Up @@ -22,7 +22,6 @@ import {
writeTranslations,
writeHeadingIds,
} from '../lib/index.js';
import {normalizePollValue} from './utils.mjs';
import beforeCli from './beforeCli.mjs';

await beforeCli();
Expand Down Expand Up @@ -105,6 +104,24 @@ cli
)
.action(deploy);

/**
*
mhnaeem marked this conversation as resolved.
Show resolved Hide resolved
* @param {string} value
* @returns {boolean|number}
*/
mhnaeem marked this conversation as resolved.
Show resolved Hide resolved
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 Down
24 changes: 0 additions & 24 deletions packages/docusaurus/bin/utils.mjs

This file was deleted.