johnlindquist / kit

Script Kit. Automate Anything.
https://scriptkit.com
MIT License
3.91k stars 138 forks source link

`clipboard.writeText` doesn't write to clipboard if it's not `string` #1350

Open ramiroaraujo opened 1 year ago

ramiroaraujo commented 1 year ago

Example:

const num:any = 123
await clipboard.writeText(num)

I know that if correctly typed it will not allow for a non-string to be passed, but I think it should either error out or do a .toString()

johnlindquist commented 1 year ago

I'll fix the internals in the next build like so:

      let text = '';
      if (typeof value === 'number') {
        text = value.toString();
      }

      if (typeof value !== 'string') {
        text = JSON.stringify(value);
      }

      if (text) {
        await clipboard.writeText(text);
      }
JosXa commented 6 months ago

@ramiroaraujo Can you confirm that this works for you now?