import { ScriptingLanguage } from './ScriptingLanguage' ; import { IScriptingDefinition } from './IScriptingDefinition' ; export class ScriptingDefinition implements IScriptingDefinition { public readonly fileExtension : string ; constructor ( public readonly language , public readonly startCode , public readonly endCode ) { this . fileExtension = findExtension ( language ) ; validateCode ( startCode , 'start code' ) ; validateCode ( endCode , 'end code' ) ; } } function findExtension ( language ) { switch ( language ) { case ScriptingLanguage . shellscript : return 'sh' ; case ScriptingLanguage . batchfile : return 'bat' ; default : throw new Error ( `unsupported language: ${ language }` ) ; } } function validateCode ( code , name ) { if ( ! code ) { throw new Error ( `undefined ${ name }` ) ; } }