import * as execa from 'execa' ; import { ErrorCode , createError } from './errors' ; import { resolve } from 'path' ; const pathToCopyApp = resolve ( `${ __dirname }/../macos/pbcopyimg` ) ; export async function copyToClipboard ( imagePath ) { if ( process . platform !== 'darwin' ) { throw createError ( ErrorCode . ClipboardPlatformUnsupported ) ; } try { await execa ( pathToCopyApp , [ imagePath ] ) ; } catch ( err ) { throw createError ( ErrorCode . CopyToClipboardFail ) ; } return true ; }