Skip to content

Commit 455c47c

Browse files
committed
feat: allow setting base
1 parent c81077f commit 455c47c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ts from 'typescript'
55

66
interface TsOptions {
77
rootDir: string
8+
base: string
89
declaration: boolean
910
emitDeclarationOnly: boolean
1011
noEmit: boolean
@@ -14,6 +15,13 @@ interface TsOptions {
1415
}
1516

1617
interface DtsOptions {
18+
/**
19+
* The base directory of the source files. If not provided, it
20+
* will use the current working directory of the process.
21+
* @default process.cwd()
22+
*/
23+
base?: string
24+
1725
/**
1826
* The TypeScript compiler options. If not provided, it will use
1927
* the `tsconfig.json` file in the current working directory.
@@ -71,11 +79,13 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
7179
try {
7280
const configJson = ts.readConfigFile(path, ts.sys.readFile).config
7381
const cwd = options?.cwd ?? process.cwd()
82+
const base = options?.base ?? cwd
7483
const rootDir = `${cwd}/${root}`
7584
const outDir = options?.outdir ?? 'dist/types'
7685
const declarationMap = options?.withSourceMap ?? false
7786

7887
const opts: TsOptions = {
88+
base,
7989
rootDir,
8090
outDir,
8191
declarationMap,

0 commit comments

Comments
 (0)