UNPKG

approvals

Version:

Approval Tests Library - Capturing Human Intelligence

41 lines (40 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const node_child_process_1 = require("node:child_process"); class CopyCommandReporter { constructor() { this.name = "CopyCommand"; } canReportOn() { return true; } report(approvedFilePath, receivedFilePath) { const programs = { win32: { clipboard: "clip", fileCopy: "copy", }, linux: { clipboard: "xclip -selection clipboard", fileCopy: "copy", }, darwin: { clipboard: "pbcopy", fileCopy: "cp", }, }; const selectedPrograms = programs[process.platform]; // EX: "copy my-file.received.txt my-file.approved.txt" const copyFragment = "'" + receivedFilePath + "' '" + approvedFilePath + "'"; if (selectedPrograms) { (0, node_child_process_1.execSync)(selectedPrograms.clipboard, { input: selectedPrograms.fileCopy + " " + copyFragment, }); } else { // some sort of fallback copy command logged to the console console.log("cp " + copyFragment); } } } exports.default = CopyCommandReporter;