Skip to content

Commit 7d83133

Browse files
committed
feat: add cwd option
1 parent 43908e1 commit 7d83133

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ await Bun.build({
3636

3737
plugins: [
3838
dts({
39+
cwd: import.meta.dir, // optional
3940
withSourceMap: true, // optional
4041
}),
4142
],

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { BunPlugin } from 'bun'
44
import ts from 'typescript'
55

66
interface TsOptions {
7+
rootDir: string
78
declaration: boolean
89
emitDeclarationOnly: boolean
910
noEmit: boolean
@@ -15,6 +16,7 @@ interface TsOptions {
1516
interface DtsOptions {
1617
compiler?: ts.CompilerOptions
1718
tsconfigPath?: string
19+
cwd?: string
1820
outDir?: ts.CompilerOptions['outDir']
1921
withSourceMap?: boolean
2022
}
@@ -24,6 +26,7 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
2426
const configJson = ts.readConfigFile(path, ts.sys.readFile).config
2527

2628
const opts: TsOptions = {
29+
rootDir: options?.cwd ?? process.cwd(),
2730
declaration: true,
2831
emitDeclarationOnly: true,
2932
noEmit: false,
@@ -34,7 +37,7 @@ export async function generate(entryPoints: string | string[], options?: DtsOpti
3437
const parsedConfig = ts.parseJsonConfigFileContent(
3538
configJson,
3639
ts.sys,
37-
process.cwd(),
40+
options?.cwd ?? process.cwd(),
3841
opts,
3942
path,
4043
)

0 commit comments

Comments
 (0)