Closed gillesdemey closed 1 year ago
hmm i'm not sure what you are asking for? why don't you just stringify your object before passing it to .entry?
That's what I did, my initial suggestion was to stringify the payload for them automatically if we detect that they're trying to write an object to the entry (most likely a JSON object)?
hmm i think that should be up the user of the module to do. we could throw if it's not a string or a buffer though to help the user though.
I think it makes sense to inform the user, but I'm wondering if it would break existing usage of the library where someone would do something like tar.entry('foo.json', {})
to write an empty buffer to the file.
Bumped my head against the wall for a while until I figured out that object serialization doesn't happen automatically when writing objects to an entry.
We could do something similar to https://github.com/mafintosh/tar-stream/blob/8e3b1749a322937238236ad05a3ec1122f32ed22/pack.js#L127 and call
JSON.stringify
on the object to prevent the user from committing an empty buffer to the file?