Skip to content

Commit

Permalink
fix(helper): keep existing user repository when checking out
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed May 11, 2024
1 parent c8f0a50 commit baf1b1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import validate from 'validate-npm-package-name'
import { log } from './log'
import { promptClear } from './prompt'

const hiddenFiles = ['.DS_Store']
const protectedFiles = ['.git'] // User checking out a template into a repository.
const invisibleFiles = [...hiddenFiles, ...protectedFiles]

function deleteFolderContents(directory: string) {
for (const file of readdirSync(directory)) {
rmSync(join(directory, file), { recursive: true })
if (!protectedFiles.includes(file)) {
rmSync(join(directory, file), { recursive: true })
}
}
}

const isDirectoryEmpty = (directory: string) => readdirSync(directory).filter((file: string) => file !== '.DS_Store').length === 0
const isDirectoryEmpty = (directory: string) => readdirSync(directory).filter((file: string) => !invisibleFiles.includes(file)).length === 0

export const getDestinationPath = async (input = process.cwd(), skipClear = false) => {
let destinationPath = process.cwd()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"mock-stdin": "^1.0.0",
"read-chunk": "^4.0.3",
"typescript": "^5.4.5",
"zero-configuration": "^0.7.2"
"zero-configuration": "^0.8.0"
},
"trustedDependencies": [
"zero-configuration"
Expand Down

0 comments on commit baf1b1b

Please sign in to comment.