clean-package icon indicating copy to clipboard operation
clean-package copied to clipboard

Package JSON specification expects string for specific keys

Open roydukkey opened this issue 1 year ago • 1 comments

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.).

https://github.com/roydukkey/clean-package/blob/a03da14f3c9cb6fae61807ec299bc724d2ecd905/src/clean.ts#L41

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 avatar Oct 02 '24 15:10 roydukkey

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"

roydukkey avatar Nov 08 '24 20:11 roydukkey