MCPcopy
hub / github.com/vercel/hyper / getPath

Function getPath

lib/utils/paste.ts:4–23  ·  view source on GitHub ↗
(platform: string)

Source from the content-addressed store, hash-verified

2import plist from 'plist';
3
4const getPath = (platform: string) => {
5 switch (platform) {
6 case 'darwin': {
7 if (clipboard.has('NSFilenamesPboardType')) {
8 // Parse plist file containing the path list of copied files
9 const list = plist.parse(clipboard.read('NSFilenamesPboardType')) as plist.PlistArray;
10 return "'" + list.join("' '") + "'";
11 } else {
12 return null;
13 }
14 }
15 case 'win32': {
16 const filepath = clipboard.read('FileNameW');
17 return filepath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
18 }
19 // Linux already pastes full path
20 default:
21 return null;
22 }
23};
24
25export default function processClipboard() {
26 return getPath(process.platform);

Callers 1

processClipboardFunction · 0.70

Calls 3

hasMethod · 0.80
parseMethod · 0.80
readMethod · 0.80

Tested by

no test coverage detected