Skip to content

Commit 3854474

Browse files
committed
feat: try to remove temp dir and restore start dir after extraction
1 parent 5c80d35 commit 3854474

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/extract-package-api.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { packageJson } from "./package-json";
1212
import { packageName } from "./package-name";
1313
import { packageOverview } from "./package-overview";
1414
import { packageTypes } from "./package-types";
15+
import { removeDir } from "./remove-dir";
1516
import { tempDir } from "./temp-dir";
1617

1718
/**
@@ -214,7 +215,16 @@ export const extractPackageApi = ({
214215
pkgDeclarations,
215216
})),
216217
)
217-
.andThen((ctx) => changeDir(ctx.startDir).map(() => ctx))
218+
.andThen((ctx) =>
219+
changeDir(ctx.startDir)
220+
.map(() => ctx)
221+
.orElse(() => ok(ctx)),
222+
)
223+
.andThen((ctx) =>
224+
removeDir(ctx.rootDir)
225+
.map(() => ctx)
226+
.orElse(() => ok(ctx)),
227+
)
218228
.andThen((ctx) =>
219229
ok({
220230
name: ctx.pkgJson.name,

0 commit comments

Comments
 (0)