()
| 49 | * コンフィグディレクトリ全体を走査してテンプレートディレクトリを取得する |
| 50 | */ |
| 51 | export async function getTemplates(): Promise<Array<Template>> { |
| 52 | const configdir = await getConfigDirectory(); |
| 53 | const files: Array<string> = await promisify(readdir)(configdir); |
| 54 | const templates = []; |
| 55 | for (const name of files) { |
| 56 | try { |
| 57 | // ファイル名をディレクトリ名とみなして直下のJSONファイルを取得 |
| 58 | const template = await getTemplate(name); |
| 59 | templates.push(template); |
| 60 | } catch (e) { |
| 61 | // ディレクトリでないファイルなど、ENOTDIR, ENOENTエラーが発生した場合はそのまま無視 |
| 62 | if (e.code !== "ENOTDIR" && e.code !== "ENOENT") console.error(`Error occurred in ${resolve(name, TEMPLATE_JSON_FILE_NAME)}:\n ${e.toString()}`); |
| 63 | } |
| 64 | } |
| 65 | return templates; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * テンプレートファイルが正しい形式に沿っているか調べる |
no test coverage detected