Skip to content

Commit

Permalink
Handle missing file error (#66)
Browse files Browse the repository at this point in the history
fixes #46
  • Loading branch information
chdsbd authored Jun 3, 2024
1 parent 0423124 commit 00b5252
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## 3.2.1 - 2024-06-02

### Fixed

- handle missing file error when opening pull request. (#66)

## 3.2.0 - 2024-06-02

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "githubinator",
"displayName": "Githubinator",
"description": "Quickly open files on Github and other providers. View blame information, copy permalinks and more. See the \"commands\" section of the README for more details.",
"version": "3.2.0",
"version": "3.2.1",
"publisher": "chdsbd",
"license": "SEE LICENSE IN LICENSE",
"icon": "images/logo256.png",
Expand Down
18 changes: 15 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ import * as fs from "fs"
export function getRelativeFilePath(
repositoryDir: string,
fileName: string,
): string {
const resolvedFileName = fs.realpathSync(fileName)
return resolvedFileName.replace(repositoryDir, "")
): string | null {
try {
const resolvedFileName = fs.realpathSync(fileName)
return resolvedFileName.replace(repositoryDir, "")
} catch (e) {
if (
typeof e === "object" &&
e != null &&
"code" in e &&
e.code === "ENOENT"
) {
return null
}
throw e
}
}

/** Convert url/hostname to hostname
Expand Down

0 comments on commit 00b5252

Please sign in to comment.