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

Update tests to check for correct URLs #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tommy-mitchell
Copy link
Contributor

@tommy-mitchell tommy-mitchell commented Jul 25, 2024

Mocks open, package-json, and console.[error/log] as needed to test for correct outputs.

Comment on lines +111 to +115
test(`github - no repository: ${flag}`, testCli, {
arguments_: [flag, 'foo'],
packageJson: {name: 'foo'},
urls: ['https://www.npmjs.com/package/foo'],
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also just realized that this message is incorrect because we fallback to opening the NPM page if the resolved package.json doesn't contain a "repository" field:

npm-home/cli.js

Lines 45 to 51 in c0e7223

const packageData = await packageJson(name, {fullMetadata: true});
const {repository} = packageData;
if (!repository) {
await openNpmOrYarn(name);
return;
}

console.error(`${logSymbols.error} No \`repository\` or \`homepage\` field found in package.json. Please open an issue or pull request on ${name}`);

@sindresorhus
Copy link
Owner

It's unclear if you planned to fix #21 (comment) in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants