import * as path from 'path' ; import { CreateUtil } from '../utils' ; import { ApexTriggerOptions } from '../utils/types' ; import { SfdxGenerator } from './sfdxGenerator' ; export default class ApexTriggerGenerator extends SfdxGenerator < ApexTriggerOptions > { constructor ( args , options ) { super ( args , options ) ; this . sourceRootWithPartialPath ( 'apextrigger' ) ; } public validateOptions ( ) { CreateUtil . checkInputs ( this . options . triggername ) ; CreateUtil . checkInputs ( this . options . template ) ; } public writing ( ) { const { template , outputdir , triggername , apiversion , triggerevents , sobject } = this . options ; this . fs . copyTpl ( this . templatePath ( `${ template }.trigger` ) , this . destinationPath ( path . join ( outputdir , `${ triggername }.trigger` ) ) , { triggername , sobject , triggerEvents : triggerevents } ) , this . fs . copyTpl ( this . templatePath ( '_trigger.trigger-meta.xml' ) , this . destinationPath ( path . join ( outputdir , `${ triggername }.trigger-meta.xml` ) ) , { apiVersion : apiversion } ) ; } }