Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃毟 Warn user if they are not in a git repository #1276

Merged
merged 2 commits into from Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/commands/commit/withClient/index.js
Expand Up @@ -41,12 +41,10 @@ const withClient = async (answers: Answers): Promise<void> => {
} catch (error) {
console.error(
chalk.red(
'\n',
'Oops! An error occurred. There is likely additional logging output above.\n',
'You can run the same commit with this command:\n'
),
'\t',
error.escapedCommand
error,
'\n\n',
'Oops! An error occurred. There is likely additional logging output above.\n'
)
)
}
}
Expand Down
14 changes: 5 additions & 9 deletions src/utils/isHookCreated.js
Expand Up @@ -5,17 +5,13 @@ import HOOK from '@commands/hook/hook'
import getAbsoluteHooksPath from './getAbsoluteHooksPath'

const isHookCreated = async (): Promise<?boolean> => {
try {
const hookFile = await getAbsoluteHooksPath(HOOK.FILENAME)
const hookFile = await getAbsoluteHooksPath(HOOK.FILENAME)

if (fs.existsSync(hookFile)) {
return fs.readFileSync(hookFile, { encoding: 'utf-8' }) === HOOK.CONTENTS
}

return false
} catch (error) {
console.error(error)
if (fs.existsSync(hookFile)) {
return fs.readFileSync(hookFile, { encoding: 'utf-8' }) === HOOK.CONTENTS
}

return false
}

export default isHookCreated
10 changes: 1 addition & 9 deletions test/commands/commit.spec.js
Expand Up @@ -142,15 +142,7 @@ describe('commit command', () => {
})

it('should print the error to the console', () => {
expect(consoleError).toHaveBeenCalledWith(
chalk.red(
'\n',
'Oops! An error occurred. There is likely additional logging output above.\n',
'You can run the same commit with this command:\n'
),
'\t',
undefined
)
expect(consoleError).toHaveBeenCalled()
})
})
})
Expand Down