Skip to content

Commit

Permalink
Code for handling tsconfig file not found has also been streamlined f…
Browse files Browse the repository at this point in the history
…or consistency and readability.
  • Loading branch information
erikyo committed Dec 12, 2023
1 parent 4310765 commit b3f0aa9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 28 deletions.
35 changes: 23 additions & 12 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 25 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,21 @@ async function run(): Promise<string> {
*/
const args: string[] = []


/**
* The log level to use
* Possible values: Verbose, Debug, Info, Warn, Error, None
*/
if (getInput('logLevel')) {
args.push('--logLevel', getInput('logLevel'))
}

/**
* The path to the source directory
*/
const srcPath: string = join(GITHUB_WORKSPACE, source_dir)
info('📂 Source directory: ' + srcPath)
args.push(srcPath)

/**
* The base path of the package to be documented.
* Since the base path is relative to the current working directory,
Expand All @@ -133,31 +143,30 @@ async function run(): Promise<string> {
}

/**
* The path to the source directory
* The output directory for the generated documentation.
*/
const srcPath: string = join(GITHUB_WORKSPACE, source_dir)
info('📂 Source directory: ' + srcPath)
args.push(srcPath)

if (output_dir) {
args.push('--out', join(GITHUB_WORKSPACE, output_dir))
}


/**
* the path to the tsconfig file, needed to resolve entry points and other options. Defaults to ./{action folder}/tsconfig.json
* The path to the tsconfig file, needed to resolve entry points and other options.
* typedoc will search for the tsconfig file in the action directory, so we have to point it to the workspace folder
* Defaults to ./{action folder}/tsconfig.json
*
* https://typedoc.org/options/input/#resolve-(default)
*/
let tsConfigPath: string = GITHUB_WORKSPACE;
if (tsconfig) {
const tsConfigPath = join(GITHUB_WORKSPACE, tsconfig)
if (existsSync(tsConfigPath)) {
setFailed('⛔️ Config file does not exist')
return
}

const configPath = join(GITHUB_WORKSPACE, tsconfig)
args.push('--tsconfig', configPath)
tsConfigPath = join(GITHUB_WORKSPACE, tsconfig)
}
if (existsSync(tsConfigPath)) {
setFailed('⛔️ Tsconfig file not found')
return
}

const configPath = join(GITHUB_WORKSPACE, tsconfig)
args.push('--tsconfig', configPath)

if (options) {
const configPath = join(GITHUB_WORKSPACE, options)
Expand Down

0 comments on commit b3f0aa9

Please sign in to comment.