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

Package JSON specification expects string for specific keys #25

Open
roydukkey opened this issue Oct 2, 2024 · 1 comment
Open

Package JSON specification expects string for specific keys #25

roydukkey opened this issue Oct 2, 2024 · 1 comment

Comments

@roydukkey
Copy link
Owner

For example, peer dependencies can simply be a numeric string ("1", "2", etc.). However, the following code converts such values to numbers (1, 2, etc.).

writeFileSync(config.sourcePath, `${JSON.stringify(source, null, config.indent)}\n`);

At the very least the values should probably maintain the same type in which they are provided. Possible using a replacer like this:

JSON.stringify(source, (key, value) => value);
@roydukkey
Copy link
Owner Author

roydukkey commented Nov 8, 2024

hummm... this appears to only affect CLI input, which is coerced into their type from strings. So this culprit doesn't appear to be the JSON stringification.

Maybe there should be some notation to prevent this coercion. For example, possibly quotes around the value.

--replace peerDependencies.depOne='1' peerDependencies.depTwo="2"

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

No branches or pull requests

1 participant