File tree 3 files changed +38
-2
lines changed
3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " superplate-cli" ,
3
- "version" : " 1.19 .0" ,
3
+ "version" : " 1.20 .0" ,
4
4
"description" : " The frontend boilerplate with superpowers" ,
5
5
"license" : " MIT" ,
6
6
"repository" : {
Original file line number Diff line number Diff line change @@ -32,4 +32,36 @@ export const GitHelper = {
32
32
throw new Error ( e instanceof Error ? e . message : ( e as string ) ) ;
33
33
}
34
34
} ,
35
+ CanGitInit : async ( root : string ) : Promise < boolean > => {
36
+ const [ isGit , isHg ] = await Promise . all ( [
37
+ isInGitRepository ( root ) ,
38
+ isInMercurialRepository ( root ) ,
39
+ ] ) ;
40
+
41
+ return ! isGit && ! isHg ;
42
+ } ,
35
43
} ;
44
+
45
+ async function isInGitRepository ( root : string ) : Promise < boolean > {
46
+ try {
47
+ await promisify ( exec ) ( "git rev-parse --is-inside-work-tree" , {
48
+ cwd : root ,
49
+ } ) ;
50
+ return true ;
51
+ } catch ( _ ) {
52
+ //
53
+ }
54
+ return false ;
55
+ }
56
+
57
+ async function isInMercurialRepository ( root : string ) : Promise < boolean > {
58
+ try {
59
+ await promisify ( exec ) ( "hg --cwd . root" , {
60
+ cwd : root ,
61
+ } ) ;
62
+ return true ;
63
+ } catch ( _ ) {
64
+ //
65
+ }
66
+ return false ;
67
+ }
Original file line number Diff line number Diff line change 3
3
extendBase ,
4
4
getPluginsArray ,
5
5
get_potential_package_managers ,
6
+ GitHelper ,
6
7
handleIgnore ,
7
8
mergeBabel ,
8
9
mergeJSONFiles ,
@@ -404,7 +405,10 @@ const saoConfig: GeneratorConfig = {
404
405
* Git init and install packages
405
406
*/
406
407
if ( ! debug ) {
407
- saoInstance . gitInit ( ) ;
408
+ const canGitInit = await GitHelper . CanGitInit ( saoInstance . outDir ) ;
409
+ if ( canGitInit ) {
410
+ saoInstance . gitInit ( ) ;
411
+ }
408
412
await saoInstance . npmInstall ( {
409
413
npmClient : npmClient ,
410
414
installArgs : [ "--silent" ] ,
You can’t perform that action at this time.
0 commit comments