const fs = require('async-file'); import * as path from 'path'; import {CommandLoader} from '../commandLoader' import {CommandTemplate} from '../../models/commandTemplate' export class LocalCommandTemplateLoader implements CommandLoader{ private _basePath: string; constructor(basePath: string){ this._basePath = basePath; } async loadCommandTemplateBy(filename: string): Promise { console.log("Looking for: ", filename); const basePath = path.join(this._basePath); const list: Array = await fs.readdir(basePath); const foundFile = list.find(file => file === filename); const template = await fs.readFile(path.join(basePath, foundFile), 'utf8'); const response = new Promise(resolve => { resolve(new CommandTemplate(foundFile, template)); }); return response; } }