Skip to content

Commit

Permalink
Change to improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Sep 25, 2023
1 parent 034930a commit 7ac7d02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/find-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export async function findRepo(file, options) {
}

if (!repo) {
throw new Error('Could not find remote origin')
throw new Error(
'Cannot find remote `origin` of local Git repo; pass `repository: false` if you are not using Git'
)
}
} else {
repo = givenRepo
Expand Down
7 changes: 5 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ test('remark-validate-links', async function (t) {
assert.fail()
} catch (error) {
const cause = /** @type {ExecError} */ (error)
assert.ok(/not a git repository/i.test(String(cause)))
assert.match(String(cause), /not a git repository/i)
} finally {
await fs.rename(gitBakUrl, gitUrl)
}
Expand All @@ -525,7 +525,10 @@ test('remark-validate-links', async function (t) {
} catch (error) {
const cause = /** @type {ExecError} */ (error)
await fs.rm('./.git', {recursive: true})
assert.ok(/Could not find remote origin/.test(String(cause)))
assert.match(
String(cause),
/Cannot find remote `origin` of local Git repo/
)
}
})

Expand Down

0 comments on commit 7ac7d02

Please sign in to comment.