import * as main from './main' ; import { Handler , Context } from 'aws-lambda' ; import { IssueParams } from './src/tasks/issue' ; console . log ( 'Node process running on' , process . pid ) ; const task = process . argv [ 2 ] ; const json = process . argv [ 3 ] ; if ( ! ( task in main ) ) { console . error ( `No task called ${ task } present` ) ; process . exit ( 1 ) ; } const handlers = ( main as unknown ) as { [ key ] : Handler < IssueParams , unknown > ; } ; const handler = handlers [ task ] ; const run = handler ( JSON . parse ( json ) , { } as Context , ( ) => null ) as Promise < any > ; run . then ( x => { console . log ( x ) ; console . log ( 'Finished.' ) ; process . exit ( 0 ) ; } ) . catch ( ( error ) => { console . error ( error ) ; process . exit ( 1 ) ; } ) ;