@@ -42,14 +42,12 @@ async function copyAllTemplateFiles(outputFilePath: string) {
4242 await fsPromise . cp ( templateDir , outputFilePath , {
4343 recursive : true ,
4444 } ) ;
45- await fsPromise . rename (
46- `${ outputFilePath } /lib.rs` ,
47- `${ outputFilePath } /src/lib.rs` ,
48- ) ;
49- await fsPromise . rename (
50- `${ outputFilePath } /gitignore` ,
51- `${ outputFilePath } /.gitignore` ,
52- ) ;
45+ await moveFile ( `${ outputFilePath } /lib.rs` , `${ outputFilePath } /src/lib.rs` ) ;
46+ await moveFile ( `${ outputFilePath } /gitignore` , `${ outputFilePath } /.gitignore` ) ;
47+ }
48+
49+ async function moveFile ( currentPath : string , newPath : string ) {
50+ await fsPromise . rename ( currentPath , newPath ) ;
5351}
5452
5553async function generateProject ( {
@@ -62,14 +60,11 @@ async function generateProject({
6260 createFolder ( outputPath ) ;
6361 createFolder ( `${ outputPath } /src` ) ;
6462 await copyAllTemplateFiles ( outputPath ) ;
63+ const strToReplace = "project_name" ;
6564 await replaceStrInFile (
6665 `${ outputPath } /package.json` ,
67- "project_name" ,
68- projectName ,
69- ) ;
70- await replaceStrInFile (
71- `${ outputPath } /Cargo.toml` ,
72- "project_name" ,
66+ strToReplace ,
7367 projectName ,
7468 ) ;
69+ await replaceStrInFile ( `${ outputPath } /Cargo.toml` , strToReplace , projectName ) ;
7570}
0 commit comments