MCPcopy Create free account
hub / github.com/Tatamo/atcoder-cli / getTemplates

Function getTemplates

src/template.ts:51–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 * コンフィグディレクトリ全体を走査してテンプレートディレクトリを取得する
50 */
51export 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 * テンプレートファイルが正しい形式に沿っているか調べる

Callers 1

getTemplateListFunction · 0.90

Calls 2

getConfigDirectoryFunction · 0.90
getTemplateFunction · 0.85

Tested by

no test coverage detected