File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { generateRoutes } from './module/generate-routes';
8
8
import { generateSpec } from './module/generate-spec' ;
9
9
import { fsExists , fsReadFile } from './utils/fs' ;
10
10
import { AbstractRouteGenerator } from './routeGeneration/routeGenerator' ;
11
- import { extname } from 'node:path' ;
11
+ import { extname , isAbsolute } from 'node:path' ;
12
12
import type { CompilerOptions } from 'typescript' ;
13
13
14
14
const workingDir : string = process . cwd ( ) ;
@@ -54,14 +54,15 @@ const isJsExtension = (extension: string): boolean => extension === '.js' || ext
54
54
const getConfig = async ( configPath = 'tsoa.json' ) : Promise < Config > => {
55
55
let config : Config ;
56
56
const ext = extname ( configPath ) ;
57
+ const configFullPath = isAbsolute ( configPath ) ? configPath : `${ workingDir } /${ configPath } `
57
58
try {
58
59
if ( isYamlExtension ( ext ) ) {
59
- const configRaw = await fsReadFile ( ` ${ workingDir } / ${ configPath } ` ) ;
60
+ const configRaw = await fsReadFile ( configFullPath ) ;
60
61
config = YAML . parse ( configRaw . toString ( 'utf8' ) ) ;
61
62
} else if ( isJsExtension ( ext ) ) {
62
- config = await import ( ` ${ workingDir } / ${ configPath } ` ) ;
63
+ config = await import ( configFullPath ) ;
63
64
} else {
64
- const configRaw = await fsReadFile ( ` ${ workingDir } / ${ configPath } ` ) ;
65
+ const configRaw = await fsReadFile ( configFullPath ) ;
65
66
config = JSON . parse ( configRaw . toString ( 'utf8' ) ) ;
66
67
}
67
68
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments