From 5bcd22610b10dcb5b29f87c5a69120cd0cbee0e7 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 18 Dec 2023 20:52:22 +0100 Subject: [PATCH] fix: don't clean root directory if set as `outDir` (#343) --- package.json | 1 + pnpm-lock.yaml | 11 +++++++---- src/build.ts | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 43f158cb..36ebc966 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a73d905..c6faeb9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ dependencies: scule: specifier: ^1.1.1 version: 1.1.1 + ufo: + specifier: ^1.3.2 + version: 1.3.2 untyped: specifier: ^1.4.0 version: 1.4.0 @@ -3170,7 +3173,7 @@ packages: acorn: 8.11.2 pathe: 1.1.1 pkg-types: 1.0.3 - ufo: 1.3.1 + ufo: 1.3.2 /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} @@ -3294,7 +3297,7 @@ packages: dependencies: destr: 2.0.2 node-fetch-native: 1.4.1 - ufo: 1.3.1 + ufo: 1.3.2 dev: true /ohash@1.1.3: @@ -4363,8 +4366,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - /ufo@1.3.1: - resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} + /ufo@1.3.2: + resolution: {integrity: sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==} /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} diff --git a/src/build.ts b/src/build.ts index d45ca3ec..c9ad738b 100644 --- a/src/build.ts +++ b/src/build.ts @@ -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"; @@ -216,7 +217,11 @@ async function _build( .filter(Boolean) .sort() as unknown as Set, )) { - 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);