@@ -12,6 +12,19 @@ class Create {
1212 this . source = source ;
1313 }
1414
15+ initGit ( ) {
16+ const commands = [ "git init" , "git add ." , "git commit -m \"initial commit\"" ] ;
17+ const finalizingLoader = ora ( chalk . blueBright ( "Finalizing..." ) ) . start ( ) ;
18+
19+ for ( const command of commands ) {
20+ try {
21+ cp . execSync ( this . path === "." ? command : `cd ${ this . path } && ${ command } ` ) ;
22+ } catch ( e ) { /* Do nothing */ }
23+ }
24+
25+ finalizingLoader . succeed ( chalk . greenBright ( "Successfully created discord bot project!" ) )
26+ }
27+
1528 async init ( token = null , ops = { language : null } ) {
1629 if ( ! this . source ) return console . log ( symbols . error , chalk . redBright ( "No source file(s) specified!" ) ) ;
1730 let path = this . path === "." ? process . cwd ( ) : `${ process . cwd ( ) } /${ this . path } ` ;
@@ -28,14 +41,16 @@ class Create {
2841 }
2942
3043 copyFileLoader . succeed ( chalk . cyanBright ( "Finished copying files!" ) ) ;
31- const finalizingLoader = ora ( chalk . blueBright ( "Finalizing ..." ) ) . start ( ) ;
44+ const depInstaller = ora ( chalk . blueBright ( "Installing dependencies ..." ) ) . start ( ) ;
3245
3346 const command = this . getInstallCommand ( ops . language ) ;
34- if ( ! command ) return finalizingLoader . warn ( chalk . yellowBright ( "Generated project but couldn't install dependencies, please try again manually!" ) ) ;
47+ if ( ! command ) return depInstaller . warn ( chalk . yellowBright ( "Generated project but couldn't install dependencies, please try again manually!" ) ) ;
48+
49+ cp . exec ( this . path === "." ? command : `cd ${ this . path } && ${ command } ` , ( error ) => {
50+ if ( error ) return depInstaller . warn ( chalk . yellowBright ( "Generated project but couldn't install dependencies, please try again manually!" ) ) ;
51+ depInstaller . succeed ( chalk . greenBright ( "Successfully Installed dependencies!" ) ) ;
3552
36- cp . exec ( command , ( error ) => {
37- if ( error ) return finalizingLoader . warn ( chalk . yellowBright ( "Generated project but couldn't install dependencies, please try again manually!" ) ) ;
38- return finalizingLoader . succeed ( chalk . greenBright ( "Successfully created discord bot project!" ) ) ;
53+ return this . initGit ( ) ;
3954 } ) ;
4055 } ) ;
4156 }
@@ -47,9 +62,6 @@ class Create {
4762 case "js" :
4863 cmd = "npm i" ;
4964 break ;
50- case "py" :
51- cmd = "pip3 install -r requirements.txt" ;
52- break ;
5365 default :
5466 cmd = null ;
5567 }
0 commit comments