@@ -3,7 +3,7 @@ import fs from "node:fs";
33import path from "node:path" ;
44
55const RenamedFiles : { [ key : string ] : string } = { } ;
6- const PageRoutes : { [ key : string ] : string } = { } ;
6+ const PageRoutes : { [ key : string ] : string } = { } ;
77
88export function randomizeName ( filePath : string ) : string {
99 const extname = path . extname ( filePath ) ;
@@ -49,9 +49,13 @@ export function RandomizeNames() {
4949 fs . renameSync ( oldPath , newPath ) ;
5050
5151 if ( file . startsWith ( path . join ( process . cwd ( ) , "src" , "pages" ) ) ) {
52- const oldRoute = oldPath . replace ( process . cwd ( ) + "/src/pages" , "" ) . replace ( / \\ / g, "/" ) ;
53- const newRoute = newPath . replace ( process . cwd ( ) + "/src/pages" , "" ) . replace ( / \\ / g, "/" ) ;
54- PageRoutes [ oldRoute ] = newRoute ;
52+ const oldRoute = oldPath
53+ . replace ( `${ process . cwd ( ) } /src/pages` , "" )
54+ . replace ( / \\ / g, "/" ) ;
55+ const newRoute = newPath
56+ . replace ( `${ process . cwd ( ) } /src/pages` , "" )
57+ . replace ( / \\ / g, "/" ) ;
58+ PageRoutes [ oldRoute ] = newRoute ;
5559 }
5660 }
5761
@@ -112,7 +116,7 @@ export function updatePageRoutes() {
112116 for ( const [ oldRoute , newRoute ] of Object . entries ( PageRoutes ) ) {
113117 fileContent = fileContent . replace (
114118 new RegExp ( `['"]${ oldRoute . replace ( ".astro" , "" ) } ['"]` , "g" ) ,
115- `'${ newRoute . replace ( ".astro" , "" ) } '`
119+ `'${ newRoute . replace ( ".astro" , "" ) } '` ,
116120 ) ;
117121 }
118122
@@ -133,7 +137,7 @@ export async function Revert() {
133137 try {
134138 console . log ( "Reverting Changes." ) ;
135139 execSync ( "git restore src/" , { cwd : process . cwd ( ) , stdio : "inherit" } ) ;
136- execSync ( "git clean -fdx src/" , { cwd : process . cwd ( ) , stdio : "inherit" } ) ;
140+ execSync ( "git clean -fdx src/" , { cwd : process . cwd ( ) , stdio : "inherit" } ) ;
137141
138142 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
139143 console . log ( "Revert completed." ) ;
0 commit comments