Skip to content

Commit 1db522a

Browse files
committed
fix: do not always output git init info
1 parent d7f40aa commit 1db522a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import renderTemplate from './utils/renderTemplate'
1515
import {
1616
postOrderDirectoryTraverse,
1717
preOrderDirectoryTraverse,
18-
hasDotGitDirectory,
18+
dotGitDirectoryState,
1919
} from './utils/directoryTraverse'
2020
import generateReadme from './utils/generateReadme'
2121
import getCommand from './utils/getCommand'
@@ -125,6 +125,7 @@ function canSkipEmptying(dir: string) {
125125
return true
126126
}
127127
if (files.length === 1 && files[0] === '.git') {
128+
dotGitDirectoryState.hasDotGitDirectory = true
128129
return true
129130
}
130131

@@ -674,7 +675,7 @@ async function init() {
674675
}
675676
outroMessage += ` ${bold(green(getCommand(packageManager, 'dev')))}\n`
676677

677-
if (!hasDotGitDirectory) {
678+
if (!dotGitDirectoryState.hasDotGitDirectory) {
678679
outroMessage += `
679680
${dim('|')} ${language.infos.optionalGitCommand}
680681

utils/directoryTraverse.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ export function preOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
1919
}
2020
}
2121

22-
export let hasDotGitDirectory = false
22+
export const dotGitDirectoryState = {
23+
hasDotGitDirectory: false,
24+
}
2325

2426
export function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
2527
for (const filename of fs.readdirSync(dir)) {
2628
if (filename === '.git') {
27-
hasDotGitDirectory = true
29+
dotGitDirectoryState.hasDotGitDirectory = true
2830
continue
2931
}
3032
const fullpath = path.resolve(dir, filename)

0 commit comments

Comments
 (0)