Skip to content

Commit

Permalink
Vendor new-github-release-url
Browse files Browse the repository at this point in the history
Fixes #340
  • Loading branch information
sindresorhus committed Jan 24, 2019
1 parent 97f017a commit 4b43c2f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -41,7 +41,6 @@
"listr-input": "^0.1.3",
"log-symbols": "^2.1.0",
"meow": "^5.0.0",
"new-github-release-url": "^0.1.0",
"npm-name": "^5.0.1",
"opn": "^5.4.0",
"ow": "^0.10.0",
Expand Down
39 changes: 39 additions & 0 deletions source/new-github-release-url.js
@@ -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();
};
2 changes: 1 addition & 1 deletion source/release-task-helper.js
@@ -1,6 +1,6 @@
'use strict';
const newGithubReleaseUrl = require('new-github-release-url');
const opn = require('opn');
const newGithubReleaseUrl = require('./new-github-release-url');
const {getTagVersionPrefix} = require('./util');
const version = require('./version');

Expand Down

0 comments on commit 4b43c2f

Please sign in to comment.