Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when GitHub URL is not defined #52 #53

Merged
merged 9 commits into from
Aug 5, 2021
9 changes: 7 additions & 2 deletions src/plugins/archive.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
const { createError } = require('../lib/result');
const { stringBuilder, success, failure } = require('../lib/format');
const { createError, createWarning } = require('../lib/result');
const { stringBuilder, success, failure, warning } = require('../lib/format');
const { fetchGithub } = require('../lib/fetch');

const archivePlugin = async (pkg, _, options) => {
if (!pkg.repository.url) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the repository field is also undefined then the if statement will throw a TypeError.

Suggested change
if (!pkg.repository.url) {
if (!pkg?.repository?.url) {

warning(output.get());
return createWarning(`No Github url found for the ${pkg.name} module`);
Copy link
Member

@aalykiot aalykiot Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return createWarning(`No Github url found for the ${pkg.name} module`);
return createWarning(`The module "${pkg.name}" does not specify its GitHub repository.`);

}

const githubTarget = pkg.repository.url
.split('github.com/')[1]
.replace('.git', '');
Expand Down