const { spawn } = require('child_process');
const copy = (text) => {
const proc = spawn('pbcopy');
proc.stdin.write(text);
proc.stdin.end();
console.log(`(${text} has been copied to the Clipboard)`);
};
copy('something'); // строка something будет в буфере обмена