Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// TODO: Remove this file and depend on `new-github-release-url` when we target Node.js 10 | ||
'use strict'; | ||
const {URL} = require('url'); | ||
|
||
module.exports = (options = {}) => { | ||
let repoUrl; | ||
if (options.repoUrl) { | ||
repoUrl = options.repoUrl; | ||
} else if (options.user && options.repo) { | ||
repoUrl = `https://github.com/${options.user}/${options.repo}`; | ||
} else { | ||
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options'); | ||
} | ||
|
||
const url = new URL(`${repoUrl}/releases/new`); | ||
|
||
const types = [ | ||
'tag', | ||
'target', | ||
'title', | ||
'body', | ||
'isPrerelease' | ||
]; | ||
|
||
for (let type of types) { | ||
const value = options[type]; | ||
if (value === undefined) { | ||
continue; | ||
} | ||
|
||
if (type === 'isPrerelease') { | ||
type = 'prerelease'; | ||
} | ||
|
||
url.searchParams.set(type, value); | ||
} | ||
|
||
return url.toString(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters