@@ -12,6 +12,19 @@ class Create {
12
12
this . source = source ;
13
13
}
14
14
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
+
15
28
async init ( token = null , ops = { language : null } ) {
16
29
if ( ! this . source ) return console . log ( symbols . error , chalk . redBright ( "No source file(s) specified!" ) ) ;
17
30
let path = this . path === "." ? process . cwd ( ) : `${ process . cwd ( ) } /${ this . path } ` ;
@@ -28,14 +41,16 @@ class Create {
28
41
}
29
42
30
43
copyFileLoader . succeed ( chalk . cyanBright ( "Finished copying files!" ) ) ;
31
- const finalizingLoader = ora ( chalk . blueBright ( "Finalizing ..." ) ) . start ( ) ;
44
+ const depInstaller = ora ( chalk . blueBright ( "Installing dependencies ..." ) ) . start ( ) ;
32
45
33
46
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!" ) ) ;
35
52
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 ( ) ;
39
54
} ) ;
40
55
} ) ;
41
56
}
@@ -47,9 +62,6 @@ class Create {
47
62
case "js" :
48
63
cmd = "npm i" ;
49
64
break ;
50
- case "py" :
51
- cmd = "pip3 install -r requirements.txt" ;
52
- break ;
53
65
default :
54
66
cmd = null ;
55
67
}
0 commit comments