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

Add a method/option to read from a string/JSON #28

Closed
tommy-mitchell opened this issue Apr 5, 2023 · 2 comments · Fixed by #29
Closed

Add a method/option to read from a string/JSON #28

tommy-mitchell opened this issue Apr 5, 2023 · 2 comments · Fixed by #29

Comments

@tommy-mitchell
Copy link
Contributor

tommy-mitchell commented Apr 5, 2023

Based on the title/synopsis, I expected this to also be able to normalize a file in memory. I wanted to do this for np (for sindresorhus/np#88):

const getPackageJsonFromLastRelease = async pkgPath => {
	const pkg = await gitUtil.readFileFromLastRelease(pkgPath);
	return readPackage(pkg);
	//=> Promise<NormalizedPackageJson>
};

Should read-pkg support this? Since normalize-package-data is already a dependency, adding this capability saves a user adding two dependencies instead of one.

@tommy-mitchell
Copy link
Contributor Author

Possible signature:

import type {PackageJson} from 'type-fest';

const parsePackage = (package: PackageJson | string) => NormalizedPackageJson;

@sindresorhus
Copy link
Owner

Possible signature:

👍

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