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

Consider dropping ow #732

Closed
tommy-mitchell opened this issue Feb 29, 2024 · 2 comments · Fixed by #733
Closed

Consider dropping ow #732

tommy-mitchell opened this issue Feb 29, 2024 · 2 comments · Fixed by #733

Comments

@tommy-mitchell
Copy link
Collaborator

We have two places we use ow - checking if an argument is a string:

np/source/npm/util.js

Lines 49 to 51 in 5d4645f

export const collaborators = async package_ => {
const packageName = package_.name;
ow(packageName, ow.string);

or checking if an argument has a specific key:

np/source/util.js

Lines 64 to 65 in 5d4645f

export const getTagVersionPrefix = pMemoize(async config => {
ow(config, ow.object.hasKeys('tagVersionPrefixCommand'));


Seems like we could just have a utility assert / invariant function:

const assert = (condition, message) => {
	if (!condition) {
		throw new Error(message);
	}
};

// …

assert(Object.hasOwn(config, 'cli'), 'config must have a cli property');
@sindresorhus
Copy link
Owner

👍

@tommy-mitchell
Copy link
Collaborator Author

Related, do we need these checks at all? Especially the packageName one - seems like that could be done at the very beginning of the CLI.

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 a pull request may close this issue.

2 participants