Skip to content

fix(cli-service): catch exception if "copy to clipboard" fails (issue #3476) #3503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2019
Merged

fix(cli-service): catch exception if "copy to clipboard" fails (issue #3476) #3503

merged 2 commits into from
Feb 26, 2019

Conversation

jonaskuske
Copy link
Contributor

As explained in issue #3476 , clipboardy throws an exception on some platforms, notably Windows Subsystem for Linux. This results in an unhandledPromiseRejection when using the --copy option.
As of right now this is just very annoying, but those rejections are deprecated and will completely stop the process in the future and so forth – you know the drill.

To prevent this I changed the copying to use writeSync() and wrapped it in a try catch-block. This also means we only log (copied to clipboard) now if copying was actually successful.

I also added a tip to the docs, it looks like this:


__copy notice


If you think this is unnecessary and we can just fail silently without mentioning it somewhere, we can also revert this commit of course :)

@jonaskuske
Copy link
Contributor Author

By the way, it should be possible to get support for WSL upstream into clipboardy (by detecting WSL and piping to clip.exe) and I'll try to land that once I have time. Still, the error handling on our side is needed imo.

@haoqunjiang haoqunjiang merged commit fec38f5 into vuejs:dev Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants