@@ -15,7 +15,7 @@ import {
1515 printUsingTemplate ,
1616 templateDescriptionString ,
1717 usageString ,
18- } from "./utils" ;
18+ } from "./utils.js " ;
1919
2020// Load package.json for version and name information
2121const packageJson = require ( "../package.json" ) as any ;
@@ -37,6 +37,15 @@ const program = new Command(packageJson.name)
3737
3838const options = program . opts ( ) ;
3939
40+ // Helper function to handle special file names during template copying
41+ function getDestinationFileName ( srcFileName : string ) : string {
42+ // Handle special cases for template files
43+ if ( srcFileName === "gitignore" ) {
44+ return ".gitignore" ;
45+ }
46+ return srcFileName ;
47+ }
48+
4049async function run ( ) {
4150 // Clean up project directory string input
4251 if ( typeof projectDir === "string" ) {
@@ -93,7 +102,19 @@ async function run() {
93102 ) ;
94103 process . exit ( 1 ) ;
95104 }
96- fs . copySync ( localTemplatePath , resolvedProjectPath ) ;
105+ // Copy files with special file name handling
106+ const templateFiles = fs
107+ . readdirSync ( localTemplatePath )
108+ . filter ( ( file ) => ! [ "node_modules" , ".git" ] . includes ( file ) ) ;
109+
110+ templateFiles . forEach ( ( file ) => {
111+ const srcPath = path . join ( localTemplatePath , file ) ;
112+ const destPath = path . join (
113+ resolvedProjectPath ,
114+ getDestinationFileName ( file )
115+ ) ;
116+ fs . copySync ( srcPath , destPath ) ;
117+ } ) ;
97118 } else {
98119 // For npm packages, first create a package.json
99120 const tempPackageJson = {
@@ -120,10 +141,13 @@ async function run() {
120141 . readdirSync ( templatePath )
121142 . filter ( ( file ) => ! [ "node_modules" , ".git" ] . includes ( file ) ) ;
122143
123- // Copy each file/directory from the template
144+ // Copy each file/directory from the template with special file name handling
124145 templateFiles . forEach ( ( file ) => {
125146 const srcPath = path . join ( templatePath , file ) ;
126- const destPath = path . join ( resolvedProjectPath , file ) ;
147+ const destPath = path . join (
148+ resolvedProjectPath ,
149+ getDestinationFileName ( file )
150+ ) ;
127151 fs . copySync ( srcPath , destPath ) ;
128152 } ) ;
129153
0 commit comments