@@ -6,6 +6,8 @@ import fs from 'node:fs';
66import { tmpdir } from 'node:os' ;
77import path from 'node:path' ;
88
9+ import { replaceUnstableOutput } from './utils.ts' ;
10+
911// Create a unique temporary directory for testing
1012const tempTmpDir = `${ tmpdir ( ) } /vite-plus-test-${ randomUUID ( ) } ` ;
1113fs . mkdirSync ( tempTmpDir , { recursive : true } ) ;
@@ -43,24 +45,19 @@ function runTestCase(name: string) {
4345 VITE_PLUS_CLI_TEST : '1' ,
4446 } ;
4547 env [ 'PATH' ] = [
46- ...env [ 'PATH' ] ! . split ( path . delimiter ) ,
4748 // Extend PATH to include the package's bin directory
48- path . resolve ( 'bin' )
49+ path . resolve ( 'bin' ) ,
50+ ...env [ 'PATH' ] ! . split ( path . delimiter ) ,
4951 ] . join ( path . delimiter ) ;
5052
5153 const newSnap : string [ ] = [ ] ;
5254
5355 for ( const command of steps . commands ) {
5456 newSnap . push ( `> ${ command } ` ) ;
5557 const output = cp . execSync ( command , { env, cwd : caseTmpDir , encoding : 'utf-8' } ) ;
56- newSnap . push ( replaceUnstableOutput ( output ) ) ;
58+ newSnap . push ( replaceUnstableOutput ( output , caseTmpDir ) ) ;
5759 }
5860 const newSnapContent = newSnap . join ( '\n' ) ;
5961
6062 fs . writeFileSync ( `${ casesDir } /${ name } /snap.txt` , newSnapContent ) ;
6163}
62-
63- function replaceUnstableOutput ( output : string ) {
64- return output . replace ( / \d + (?: \. \d + ) ? s | \d + m s / , '<variable>ms' )
65- . replace ( / w i t h \d + r u l e s u s i n g \d + t h r e a d s / , 'with <variable> rules using <variable> threads' ) ;
66- }
0 commit comments