Skip to content

Commit a0af5a7

Browse files
committed
fix: allow for relative paths for changelog file
Re nodejs/node#57343 (comment) Signed-off-by: flakey5 <[email protected]>
1 parent 97b3495 commit a0af5a7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/releases.mjs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,25 @@ const getChangelogFromFileSystem = async changelogUrl =>
3535
* @param {string} changelogPath The given URL to the Node.js CHANGELOG.md file
3636
*/
3737
const createNodeReleases = changelogPath => {
38-
const changelogUrl = new URL(changelogPath);
38+
/**
39+
* @type {Promise<string>}
40+
*/
41+
let changelogStrategy;
42+
43+
try {
44+
const changelogUrl = new URL(changelogPath);
45+
46+
changelogStrategy =
47+
changelogUrl.protocol === 'file:'
48+
? getChangelogFromFileSystem(changelogUrl)
49+
: getChangelogFromNetwork(changelogUrl);
50+
} catch (err) {
51+
if (err.code !== 'ERR_INVALID_URL') {
52+
throw err;
53+
}
3954

40-
const changelogStrategy =
41-
changelogUrl.protocol === 'file:'
42-
? getChangelogFromFileSystem(changelogUrl)
43-
: getChangelogFromNetwork(changelogUrl);
55+
changelogStrategy = getChangelogFromFileSystem(changelogPath);
56+
}
4457

4558
/**
4659
* Retrieves all Node.js major versions from the provided CHANGELOG.md file

0 commit comments

Comments
 (0)