pnpm / meta-updater

MIT License
54 stars 6 forks source link

Support custom clone operation #10

Open pokey opened 1 year ago

pokey commented 1 year ago

I'm trying to update a yaml file while preserving comments, using the yaml npm library. In order to preserve comments, I need the parsed file to be a yaml.Document, but that cannot be cloned using the default clone method provided by meta-updater. It would be great if custom formats supported an optional clone field that I could use to provide my own cloning methodology (I'd just use Document.clone).

I would be happy to contribute a PR

Fwiw, the error I get today is as follows:

DOMException [DataCloneError]: (value) => value instanceof Uint8Array could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at structuredClone (node:internal/structured_clone:23:17)
    at performUpdates (file:///Users/pokey/src/cursorless/node_modules/.pnpm/@pnpm+meta-updater@0.2.2_typanion@3.12.1/node_modules/@pnpm/meta-updater/lib/index.js:51:56)
    at async default (file:///Users/pokey/src/cursorless/node_modules/.pnpm/@pnpm+meta-updater@0.2.2_typanion@3.12.1/node_modules/@pnpm/meta-updater/lib/index.js:16:20)