Skip to content

Commit eacb0c8

Browse files
committed
chore: update
1 parent fb95918 commit eacb0c8

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

packages/plugin-dts/src/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,12 @@ export function warnIfOutside(
517517
label: string,
518518
): void {
519519
if (dir) {
520-
const relDir = relative(cwd, dir);
521-
if (relDir.startsWith('..') || relDir.startsWith('/')) {
520+
const normalizedCwd = normalize(cwd);
521+
const normalizedDir = normalize(dir);
522+
const relDir = relative(normalizedCwd, normalizedDir);
523+
if (relDir.startsWith('..') || relDir.startsWith(path.sep)) {
522524
logger.warn(
523-
`The resolved ${label} ${color.cyan(normalizeSlash(dir))} is outside the project root ${color.cyan(normalizeSlash(cwd))}, please check your tsconfig file.`,
525+
`The resolved ${label} ${color.cyan(normalizedDir)} is outside the project root ${color.cyan(normalizedCwd)}, please check your tsconfig file.`,
524526
);
525527
}
526528
}

tests/integration/dts/index.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync } from 'node:fs';
2-
import path, { join } from 'node:path';
2+
import { join, normalize } from 'node:path';
33
import stripAnsi from 'strip-ansi';
44
import {
55
buildAndGetResults,
@@ -617,14 +617,15 @@ describe('check tsconfig.json field', async () => {
617617
type: 'dts',
618618
});
619619
const logStrings = logs.map((log) => stripAnsi(log));
620+
restore();
620621

621-
const expectDeclarationDir = join(__dirname, 'check/tsconfig/dist')
622-
.split(path.sep)
623-
.join('/');
624-
const expectRoot = join(__dirname, 'check/outside-root')
625-
.split(path.sep)
626-
.join('/');
627-
622+
const expectDeclarationDir = normalize(
623+
join(__dirname, 'check/tsconfig/dist'),
624+
);
625+
const expectRoot = normalize(join(__dirname, 'check/outside-root'));
626+
console.log('expectDeclarationDir: ', expectDeclarationDir);
627+
console.log('expectRoot: ', expectRoot);
628+
console.log('logStrings: ', logStrings);
628629
expect(
629630
logStrings.some((log) =>
630631
log.includes(
@@ -634,7 +635,5 @@ describe('check tsconfig.json field', async () => {
634635
).toEqual(true);
635636

636637
expect(files.esm).toMatchInlineSnapshot('undefined');
637-
638-
restore();
639638
});
640639
});

0 commit comments

Comments
 (0)