pkg icon indicating copy to clipboard operation
pkg copied to clipboard

Support for clipboardy

Open brozef opened this issue 9 years ago • 11 comments

from my experience copy-paste has several issues - which clipboardy does not. Would it be possible to add in support? https://github.com/sindresorhus/clipboardy

brozef avatar Aug 28 '17 13:08 brozef

Have you tried using clipboardy within an app packaged with pkg and it failed? It seems to work fine for me.

gabemarshall avatar Sep 05 '17 15:09 gabemarshall

@gabemarshall that's great to hear. I have come into problems with the app packaged from pkg not being able to find the copy or paste executables on windows - i have not attempted on other OS's.

brozef avatar Sep 06 '17 00:09 brozef

I can confirm that both modules fail when called from inside a binary built with pkg on Windows. Here is clipboardy:

Error: spawn C:\\snapshot\\vagrant\\node_modules\\clipboardy\\fallbacks\\windows\\paste.exe

And node-copy-paste:

Error: Command failed: cscript /Nologo C:\snapshot\Users\IEUser\myapp\node_modules\copy-paste\platform\fallbacks\paste.vbs

d-rep avatar Sep 06 '17 20:09 d-rep

yeah the issue is clipboardy provides its own exes for utilizing the clipboard. Not much pkg can do to fix that - although it seemed like they had added a patch to support for node-copy-paste in the past.

brozef avatar Sep 07 '17 05:09 brozef

Ahh yes sorry about that, wasn't thinking of Windows support when I first read the issue. I'll look into it this weekend (I have a project that needs copy/paste support as well).

gabemarshall avatar Sep 07 '17 20:09 gabemarshall

Any updates regarding this? I have a project that requires copy/paste support and pkg and clipboardy still do not work together.

slbls avatar Apr 22 '18 17:04 slbls

I am also looking for support for clipboardy within pkg or a workaround to use it as an uncompiled external module. Any updates?

Update: I found a quick half solution to include the uncompiled clipboardy module by doing the following: const path = require('path'); const clipboard = require(path.join(process.cwd(), '/node_modules/clipboardy'));

and then just have the node_modules folder available inside the directory with the pkged script.

I'd still like to find a solution that pkgs everything into a single executable.

LinkTree3 avatar Sep 25 '18 19:09 LinkTree3

Apologies for committing over a year ago to look into this and letting it fall by the wayside. I'm taking another look now based on the idea I had and will hopefully come back with some good news shortly.

gabemarshall avatar Sep 26 '18 14:09 gabemarshall

For now I ended up writing a simple patch script that iterates over the "lib" directory files and searches their text for all the occurrences of the fallback executables paths and rewrites the matched paths with paths to the current working directory. Then it copies the executables to the working dir.

Thank you for looking further into it @gabemarshall

LinkTree3 avatar Sep 26 '18 14:09 LinkTree3

@LinkTree3 @JoeNimble I have a modified fork of node-copy-paste that seems to work fine, but it could use some additional testing if you have a chance. I'm sure something similar could be implemented into clipboardy if necesary.

https://github.com/gabemarshall/node-copy-paste https://github.com/gabemarshall/node-copy-paste/blob/master/platform/win32.js

gabemarshall avatar Sep 26 '18 15:09 gabemarshall

@gabemarshall I haven't tested it yet but I did go over your code and it looks wonderful. That ps script to create a new htmlfile object and get the clipboard data from it is really cool.

I personally wanted to use Clipboardy because it seems to be cleaner and more well supported

LinkTree3 avatar Sep 26 '18 16:09 LinkTree3