KnodesCommunity / typedoc-plugins

A monorepo containing all knodes-published TypeDoc plugins
https://knodescommunity.github.io/typedoc-plugins/
MIT License
20 stars 4 forks source link

[Bug]: rootDir assumes --options is used and config file is in project root #525

Open pjeby opened 10 months ago

pjeby commented 10 months ago

Plugin

@knodes/typedoc-pluginutils

Typedoc plugin(s) version(s)

@knodes/typedoc-pluginutils@0.23.4, @knodes/typedoc-plugin-pages@0.23.4

Typedoc version

0.25.4

Describe the problem

The rootDir calculation in ABasePlugin makes two invalid assumptions that result in errors in some projects.

First, if --options has been specified, but the options file is in a subdirectory of the project, the selected root directory is incorrect.

Second, if --options has not been specified as a command-line argument, it tries to statSync(undefined) (in rootDir from utils/misc.js).

What did you expected ?

The rootDir to be calculated independently of --options and without throwing an error.

pjeby commented 10 months ago

A workaround for anyone experiencing this issue: you can add "options": "package.json", (or some other file in your project root) to your config file. Typedoc will ignore it since it'll have already loaded the options when it sees it, but pluginutils and the pages plugin will see what they're looking for.