diff options
Diffstat (limited to 'packages/cli/src/ui/commands')
| -rw-r--r-- | packages/cli/src/ui/commands/setupGithubCommand.test.ts | 4 | ||||
| -rw-r--r-- | packages/cli/src/ui/commands/setupGithubCommand.ts | 19 |
2 files changed, 17 insertions, 6 deletions
diff --git a/packages/cli/src/ui/commands/setupGithubCommand.test.ts b/packages/cli/src/ui/commands/setupGithubCommand.test.ts index 891c84e7..ae6378c7 100644 --- a/packages/cli/src/ui/commands/setupGithubCommand.test.ts +++ b/packages/cli/src/ui/commands/setupGithubCommand.test.ts @@ -61,6 +61,8 @@ describe('setupGithubCommand', () => { vi.mocked(child_process.execSync).mockReturnValue(''); expect(() => { setupGithubCommand.action?.({} as CommandContext, ''); - }).toThrow('Unable to determine the Git root directory.'); + }).toThrow( + 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.', + ); }); }); diff --git a/packages/cli/src/ui/commands/setupGithubCommand.ts b/packages/cli/src/ui/commands/setupGithubCommand.ts index 445c0e76..047e11eb 100644 --- a/packages/cli/src/ui/commands/setupGithubCommand.ts +++ b/packages/cli/src/ui/commands/setupGithubCommand.ts @@ -19,12 +19,21 @@ export const setupGithubCommand: SlashCommand = { description: 'Set up GitHub Actions', kind: CommandKind.BUILT_IN, action: (): SlashCommandActionReturn => { - const gitRootRepo = execSync('git rev-parse --show-toplevel', { - encoding: 'utf-8', - }).trim(); - if (!isGitHubRepository()) { - throw new Error('Unable to determine the Git root directory.'); + throw new Error( + 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.', + ); + } + + let gitRootRepo: string; + try { + gitRootRepo = execSync('git rev-parse --show-toplevel', { + encoding: 'utf-8', + }).trim(); + } catch { + throw new Error( + 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.', + ); } const version = 'v0'; |
