From b1f3026c19e3148a4b7b2df88d5f1de8b41a0c55 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Sun, 30 Jul 2023 06:09:03 -0600 Subject: [PATCH] feat: pull string from clipboard repl globals --- src/repl_globals.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/repl_globals.js b/src/repl_globals.js index 0184fdc..913eecc 100644 --- a/src/repl_globals.js +++ b/src/repl_globals.js @@ -68,6 +68,22 @@ function copyToClipboard(text) { } global.copyToClipboard = copyToClipboard +function stringFromClipboard() { + const result = require("child_process").spawnSync("/usr/bin/pbpaste", [], { + env: { + LC_CTYPE: "UTF-8", + }, + }); + + if (result.error) { + console.error('Error:', result.error); + return null; + } + + return result.stdout.toString(); +} +global.stringFromClipboard = stringFromClipboard + // https://stackoverflow.com/questions/332422/get-the-name-of-an-objects-type function getClassName(target) { const funcNameRegex = /function (.{1,})\(/