Skip to content

Commit

Permalink
fix(docutils): fix bad option name and ignore most falsy args
Browse files Browse the repository at this point in the history
- in type `DeployOpts`, `mkDocsYml` should have been `mkdocsYml`
- arguments were only being omitted from being passed to `mike` if they were `false`, but it needed to also consider `undefined` values and empty string values.  `0` is falsy, but we should not disallow this.  thus... "most" falsy values get ignored.
  • Loading branch information
boneskull committed Feb 9, 2023
1 parent 322363b commit 5446e5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/appium/docs/scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function main() {
log.info(`Building docs for language '${lang}' and version ${majMinVer}`);
const configFile = path.join(DOCS_DIR, `mkdocs-${lang}.yml`);
await deploy({
mkDocsYml: configFile,
mkdocsYml: configFile,
branch,
prefix: path.join(basePrefix, lang),
remote,
Expand Down
14 changes: 10 additions & 4 deletions packages/docutils/lib/builder/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function findDeployVersion(packageJsonPath?: string, cwd = process.cwd()):
* @param opts Options
*/
export async function deploy({
mkDocsYml: mkDocsYmlPath,
mkdocsYml: mkDocsYmlPath,
packageJson: packageJsonPath,
deployVersion: version,
cwd = process.cwd(),
Expand Down Expand Up @@ -111,7 +111,10 @@ export async function deploy({
host,
};
if (serve) {
const mikeArgs = [...argify(_.pickBy(mikeOpts, Boolean)), version];
const mikeArgs = [
...argify(_.pickBy(mikeOpts, (value) => _.isNumber(value) || Boolean(value))),
version,
];
if (alias) {
mikeArgs.push(alias);
}
Expand All @@ -120,7 +123,10 @@ export async function deploy({
} else {
const mikeArgs = [
...argify(
_.omitBy(mikeOpts, (value, key) => _.includes(['port', 'host'], key) || value === false)
_.omitBy(
mikeOpts,
(value, key) => _.includes(['port', 'host'], key) || (!_.isNumber(value) && !value)
)
),
version,
];
Expand All @@ -140,7 +146,7 @@ export interface DeployOpts {
/**
* Path to `mike.yml`
*/
mkDocsYml?: string;
mkdocsYml?: string;

/**
* Current working directory
Expand Down

0 comments on commit 5446e5c

Please sign in to comment.