File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 11import { existsSync } from 'node:fs' ;
2- import path , { join } from 'node:path' ;
2+ import { join , normalize } from 'node:path' ;
33import stripAnsi from 'strip-ansi' ;
44import {
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} ) ;
You can’t perform that action at this time.
0 commit comments