@@ -47,6 +47,7 @@ interface ParsedArgs extends yargs.Arguments {
47
47
'export-referenced-types' : boolean ;
48
48
49
49
'out-file' : string | undefined ;
50
+ 'out-dir' : string | undefined ;
50
51
'umd-module-name' : string | undefined ;
51
52
project: string | undefined ;
52
53
config: string | undefined ;
@@ -71,6 +72,11 @@ function parseArgs(): ParsedArgs {
71
72
type : 'string' ,
72
73
description : 'File name of generated d.ts' ,
73
74
} )
75
+ . option ( 'out-dir' , {
76
+ type : 'string' ,
77
+ description : 'Output directory for genereated d.ts files.\n' +
78
+ 'For when specifying multiple entries' ,
79
+ } )
74
80
. option ( 'verbose' , {
75
81
type : 'boolean' ,
76
82
default : false ,
@@ -199,9 +205,23 @@ function main(): void {
199
205
200
206
bundlerConfig = {
201
207
entries : args . _ . map < ConfigEntryPoint > ( ( entryPath : string | number ) => {
208
+ let outFile ;
209
+
210
+ if ( args [ 'out-dir' ] ) {
211
+ const { dir, name } = path . parse ( String ( entryPath ) ) ;
212
+
213
+ if ( args . project ) {
214
+ outFile = path . join ( args [ 'out-dir' ] , path . relative ( path . dirname ( args . project ) , dir ) , name + '.d.ts' ) ;
215
+ } else {
216
+ outFile = path . join ( args [ 'out-dir' ] , dir , name + '.d.ts' ) ;
217
+ }
218
+ } else {
219
+ outFile = args [ 'out-file' ] ;
220
+ }
221
+
202
222
return {
203
223
filePath : String ( entryPath ) ,
204
- outFile : args [ 'out-file' ] ,
224
+ outFile,
205
225
noCheck : args [ 'no-check' ] ,
206
226
libraries : {
207
227
allowedTypesLibraries : args [ 'external-types' ] ,
0 commit comments