Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 7883bfa

Browse files
authored
better error handling for link when git repo not found (#32)
* better error handling for link when git repo not found * .
1 parent f71aa1d commit 7883bfa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/commands/link/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default class LinkIndex extends Command {
104104
const gitConfigFilePath = getGitConfigFilePath()
105105

106106
if (!fileExists(gitConfigFilePath)) {
107-
throw new Error('No remote git repository found')
107+
throw new Error(chalk.red('No .git found in this directory. Please initialize a git repository with `git init`.'))
108108
}
109109

110110
const gitUrl = getGitRemoteUrl(gitConfigFilePath)

src/util/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function getGitRemoteUrl(filePath: string): string {
114114
const content = fs.readFileSync(filePath, 'utf8')
115115
const remoteMatch = content.match(/\[remote "origin"]\n\s+url = (.*)/)
116116
if (!remoteMatch) {
117-
throw new Error('No remote origin found in .git/config')
117+
throw new Error(chalk.red('No remote origin found in .git/config, please set up a remote origin with `git remote add origin <url>`.'))
118118
}
119119

120120
return remoteMatch[1]

0 commit comments

Comments
 (0)