fix(cli-service): catch exception if "copy to clipboard" fails (issue #3476) #3503
+11
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As explained in issue #3476 ,
clipboardy
throws an exception on some platforms, notably Windows Subsystem for Linux. This results in anunhandledPromiseRejection
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 atry 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:
If you think this is unnecessary and we can just fail silently without mentioning it somewhere, we can also revert this commit of course :)