From c264b0adb451fed9357b30d26e033fc78af3a648 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Fri, 8 Nov 2019 00:04:08 +0100 Subject: [PATCH] refactor: remove clipboardy dep --- package.json | 1 - src/client/RPCClient.ts | 19 ++++++++++--------- yarn.lock | 14 -------------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index f461863..e3cde83 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,6 @@ }, "dependencies": { "bufferutil": "^4.0.1", - "clipboardy": "^2.1.0", "discord-rpc": "discordjs/RPC", "register-scheme": "devsnek/node-register-scheme", "utf-8-validate": "^5.0.2", diff --git a/src/client/RPCClient.ts b/src/client/RPCClient.ts index 38cbc2a..26e3f67 100644 --- a/src/client/RPCClient.ts +++ b/src/client/RPCClient.ts @@ -1,10 +1,9 @@ const { Client } = require('discord-rpc'); // eslint-disable-line -import { Disposable, StatusBarItem, Uri, window, workspace } from 'vscode'; +import { Disposable, StatusBarItem, Uri, window, workspace, env } from 'vscode'; import * as vsls from 'vsls'; import Activity from '../structures/Activity'; import Logger from '../structures/Logger'; import { API } from '../git'; -import * as clipboardy from 'clipboardy'; let activityTimer: NodeJS.Timer; @@ -92,9 +91,10 @@ export default class RPCClient implements Disposable { // VS Liveshare has this annoying bug where you convert a URL string to a URI object to autofill // But the autofill will be empty, so to circumvent this I need to add copying the link to the clipboard // And immediately pasting it after the window pops up empty - await clipboardy.write(s); - await liveshare.join(Uri.parse(s)); - await clipboardy.read(); + await env.clipboard.writeText(s); + const uriString = await env.clipboard.readText(); + const uri = Uri.parse(uriString); + await liveshare.join(uri); } catch (error) { Logger.log(error); } @@ -124,10 +124,11 @@ export default class RPCClient implements Disposable { try { const s = Buffer.from(secret, 'base64').toString(); // You might be asking yourself again again: "but why?" - // See first comment on clipboardy above - await clipboardy.write(s); - await liveshare.join(Uri.parse(s)); - await clipboardy.read(); + // See first comment above + await env.clipboard.writeText(s); + const uriString = await env.clipboard.readText(); + const uri = Uri.parse(uriString); + await liveshare.join(uri); } catch (error) { Logger.log(error); } diff --git a/yarn.lock b/yarn.lock index db25237..a855106 100644 --- a/yarn.lock +++ b/yarn.lock @@ -457,11 +457,6 @@ aproba@^1.0.3, aproba@^1.1.1: resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== -arch@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/arch/-/arch-2.1.1.tgz#8f5c2731aa35a30929221bb0640eed65175ec84e" - integrity sha512-BLM56aPo9vLLFVa8+/+pJLnrZ7QGGTVHWsCwieAWT9o9K8UeGaQbzZbGoabWLOo2ksBCztoXdqBZBplqLDDCSg== - are-we-there-yet@~1.1.2: version "1.1.5" resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21" @@ -948,14 +943,6 @@ cli-width@^2.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= -clipboardy@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/clipboardy/-/clipboardy-2.1.0.tgz#0123a0c8fac92f256dc56335e0bb8be97a4909a5" - integrity sha512-2pzOUxWcLlXWtn+Jd6js3o12TysNOOVes/aQfg+MT/35vrxWzedHlLwyoJpXjsFKWm95BTNEcMGD9+a7mKzZkQ== - dependencies: - arch "^2.1.1" - execa "^1.0.0" - cliui@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" @@ -3446,7 +3433,6 @@ prettier-linter-helpers@^1.0.0: prettier@prettier/prettier: version "1.18.2" - uid d4a7a47b048b8ced046e71d44dfc5de417b89221 resolved "https://codeload.github.com/prettier/prettier/tar.gz/d4a7a47b048b8ced046e71d44dfc5de417b89221" dependencies: "@angular/compiler" "8.2.13"