Skip to content

Commit

Permalink
fixed options for typedoc 0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
gdelmas committed Mar 8, 2020
1 parent 487f728 commit 129b69b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/SourcefileUrlMapPlugin.ts
Expand Up @@ -24,24 +24,23 @@ export class SourcefileUrlMapPlugin extends ConverterComponent {

private onBegin(): void
{
// read options parameter
const options: Options = this.application.options
const mapRelativePath = options.getValue('sourcefile-url-map')
const urlPrefix = options.getValue('sourcefile-url-prefix')
// read options parameters
const mapRelativePath = this.readStringOption('sourcefile-url-map')
const urlPrefix = this.readStringOption('sourcefile-url-prefix')

if ( (typeof mapRelativePath !== 'string') && (typeof urlPrefix !== 'string') ) {
if ( !mapRelativePath && !urlPrefix ) {
return
}

try {
if ( (typeof mapRelativePath === 'string') && (typeof urlPrefix === 'string') ) {
if ( mapRelativePath && urlPrefix ) {
throw new Error('use either --sourcefile-url-prefix or --sourcefile-url-map option')
}

if ( typeof mapRelativePath === 'string' ) {
if ( mapRelativePath ) {
this.readMappingJson(mapRelativePath)
}
else if ( typeof urlPrefix === 'string' ) {
else if ( urlPrefix ) {
this.mappings = [{
pattern: new RegExp('^'),
replace: urlPrefix
Expand All @@ -56,6 +55,17 @@ export class SourcefileUrlMapPlugin extends ConverterComponent {
}
}

private readStringOption(name: string): string | undefined {
const options: Options = this.application.options
const value = options.getValue(name)

if (typeof value !== "string") {
return undefined
}

return value
}

private readMappingJson(mapRelativePath: string): void
{
// load json
Expand Down

0 comments on commit 129b69b

Please sign in to comment.