(platform: string)
| 2 | import plist from 'plist'; |
| 3 | |
| 4 | const 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 | |
| 25 | export default function processClipboard() { |
| 26 | return getPath(process.platform); |
no test coverage detected