File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,8 +116,6 @@ Done in 171ms using pnpm v10.16.1
116116
117117 describe . skipIf ( process . platform !== 'win32' ) ( 'Windows cwd replacement' , ( ) => {
118118 test ( 'mixed-separator cwd matches all-backslash output' , ( ) => {
119- // Simulates the CI failure: cwd has mixed separators (template literal),
120- // but Vite outputs all-backslash paths (path.resolve)
121119 const cwd =
122120 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp/vite-plus-test-abc/command-staged-broken-config' ;
123121 const output =
@@ -127,6 +125,14 @@ Done in 171ms using pnpm v10.16.1
127125 ) ;
128126 } ) ;
129127
128+ test ( 'mixed-separator cwd matches all-forward-slash output' , ( ) => {
129+ const cwd =
130+ 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp/vite-plus-test-abc/vite-plugins-async-test' ;
131+ const output =
132+ ' RUN C:/Users/RUNNER~1/AppData/Local/Temp/vite-plus-test-abc/vite-plugins-async-test\n' ;
133+ expect ( replaceUnstableOutput ( output , cwd ) ) . toBe ( ' RUN <cwd>\n' ) ;
134+ } ) ;
135+
130136 test ( 'all-backslash cwd matches all-backslash output' , ( ) => {
131137 const cwd = 'C:\\Users\\runner\\project' ;
132138 const output = 'error in C:\\Users\\runner\\project\\src\\main.ts' ;
Original file line number Diff line number Diff line change @@ -32,14 +32,16 @@ export function replaceUnstableOutput(output: string, cwd?: string) {
3232
3333 if ( cwd ) {
3434 // On Windows, cwd may have mixed separators (from template literals like `${tmp}/name`)
35- // while output uses all-backslash paths (from path.resolve()). Replace the all-backslash
36- // form of each path token, with trailing separator first so the separator after the
37- // placeholder is normalized to forward slash.
35+ // while output may use all-backslash OR all-forward-slash paths depending on the tool.
36+ // Try all three forms: all-backslash, all-forward-slash, and original mixed.
3837 const replacePathToken = ( rawPath : string , placeholder : string ) => {
3938 if ( process . platform === 'win32' ) {
4039 const backslash = rawPath . replaceAll ( '/' , '\\' ) ;
4140 output = output . replaceAll ( backslash + '\\' , placeholder + '/' ) ;
4241 output = output . replaceAll ( backslash , placeholder ) ;
42+ const forwardslash = rawPath . replaceAll ( '\\' , '/' ) ;
43+ output = output . replaceAll ( forwardslash + '/' , placeholder + '/' ) ;
44+ output = output . replaceAll ( forwardslash , placeholder ) ;
4345 }
4446 output = output . replaceAll ( rawPath , placeholder ) ;
4547 } ;
You can’t perform that action at this time.
0 commit comments