import { AppsCommands } from "../sharedTypes" ; export function tryRequire < T > ( path , alternative ) { try { return require ( path ) ; } catch ( e ) { return alternative ; } } export const onUpdateCommand = < T > ( cb ) => { process . on ( "message" , ( message ) => { if ( ! message . kind ) { console . warn ( `got an unknown message from process, skipping it` , message ) ; return ; } const command = message as AppsCommands ; if ( command . kind == "update-app-state" ) cb ( command . state ) ; } ) ; } ;