Skip to content

Commit

Permalink
fix: don't clean root directory if set as outDir (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Dec 18, 2023
1 parent a7acd7e commit 5bcd226
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"rollup": "^4.6.1",
"rollup-plugin-dts": "^6.1.0",
"scule": "^1.1.1",
"ufo": "^1.3.2",
"untyped": "^1.4.0"
},
"devDependencies": {
Expand Down
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Module from "node:module";
import { promises as fsp } from "node:fs";
import { resolve, relative, isAbsolute, normalize } from "pathe";
import { withTrailingSlash } from "ufo";
import type { PackageJson } from "pkg-types";
import chalk from "chalk";
import { consola } from "consola";
Expand Down Expand Up @@ -216,7 +217,11 @@ async function _build(
.filter(Boolean)
.sort() as unknown as Set<string>,
)) {
if (cleanedDirs.some((c) => dir.startsWith(c))) {
if (
dir === options.rootDir ||
options.rootDir.startsWith(withTrailingSlash(dir)) ||
cleanedDirs.some((c) => dir.startsWith(c))
) {
continue;
}
cleanedDirs.push(dir);
Expand Down

0 comments on commit 5bcd226

Please sign in to comment.