Skip to content

Commit 00b5252

Browse files
authored
Handle missing file error (#66)
fixes #46
1 parent 0423124 commit 00b5252

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## 3.2.1 - 2024-06-02
11+
12+
### Fixed
13+
14+
- handle missing file error when opening pull request. (#66)
15+
1016
## 3.2.0 - 2024-06-02
1117

1218
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "githubinator",
33
"displayName": "Githubinator",
44
"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.",
5-
"version": "3.2.0",
5+
"version": "3.2.1",
66
"publisher": "chdsbd",
77
"license": "SEE LICENSE IN LICENSE",
88
"icon": "images/logo256.png",

src/utils.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ import * as fs from "fs"
44
export function getRelativeFilePath(
55
repositoryDir: string,
66
fileName: string,
7-
): string {
8-
const resolvedFileName = fs.realpathSync(fileName)
9-
return resolvedFileName.replace(repositoryDir, "")
7+
): string | null {
8+
try {
9+
const resolvedFileName = fs.realpathSync(fileName)
10+
return resolvedFileName.replace(repositoryDir, "")
11+
} catch (e) {
12+
if (
13+
typeof e === "object" &&
14+
e != null &&
15+
"code" in e &&
16+
e.code === "ENOENT"
17+
) {
18+
return null
19+
}
20+
throw e
21+
}
1022
}
1123

1224
/** Convert url/hostname to hostname

0 commit comments

Comments
 (0)