File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -506,21 +506,18 @@ export async function cleanTsBuildInfoFile(
506506 }
507507}
508508
509- const windowsSlashRegex = / \\ / g;
510- export function normalizeSlash ( p : string ) : string {
511- return p . replace ( windowsSlashRegex , '/' ) ;
512- }
513-
514509export function warnIfOutside (
515510 cwd : string ,
516511 dir : string | undefined ,
517512 label : string ,
518513) : void {
519514 if ( dir ) {
520- const relDir = relative ( cwd , dir ) ;
521- if ( relDir . startsWith ( '..' ) || relDir . startsWith ( '/' ) ) {
515+ const normalizedCwd = normalize ( cwd ) ;
516+ const normalizedDir = normalize ( dir ) ;
517+ const relDir = relative ( normalizedCwd , normalizedDir ) ;
518+ if ( relDir . startsWith ( '..' ) || relDir . startsWith ( path . sep ) ) {
522519 logger . warn (
523- `The resolved ${ label } ${ color . cyan ( normalizeSlash ( dir ) ) } is outside the project root ${ color . cyan ( normalizeSlash ( cwd ) ) } , please check your tsconfig file.` ,
520+ `The resolved ${ label } ${ color . cyan ( normalizedDir ) } is outside the project root ${ color . cyan ( normalizedCwd ) } , please check your tsconfig file.` ,
524521 ) ;
525522 }
526523 }
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,13 +617,12 @@ 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 ( '/' ) ;
622+ const expectDeclarationDir = normalize (
623+ join ( __dirname , 'check/tsconfig/dist' ) ,
624+ ) ;
625+ const expectRoot = normalize ( join ( __dirname , 'check/outside-root' ) ) ;
627626
628627 expect (
629628 logStrings . some ( ( log ) =>
@@ -634,7 +633,5 @@ describe('check tsconfig.json field', async () => {
634633 ) . toEqual ( true ) ;
635634
636635 expect ( files . esm ) . toMatchInlineSnapshot ( 'undefined' ) ;
637-
638- restore ( ) ;
639636 } ) ;
640637} ) ;
You can’t perform that action at this time.
0 commit comments