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

Function saveProjectJSON

src/project.ts:113–125  ·  view source on GitHub ↗
(data: ContestProject, directory_path?: string)

Source from the content-addressed store, hash-verified

111 * @param directory_path 省略した場合は自動的にプロジェクトディレクトリを探してプロジェクトファイルを上書きする
112 */
113export async function saveProjectJSON(data: ContestProject, directory_path?: string): Promise<void> {
114 if (directory_path === undefined) directory_path = (await findProjectJSON()).path;
115 if (directory_path === undefined) throw new Error("Cannot find project directory path");
116 const [valid, error] = await validateProjectJSON(data);
117 if (valid) {
118 const json_data = JSON.stringify(data, undefined, 2);
119 await promisify(writeFile)(resolve(directory_path, PROJECT_JSON_FILE_NAME), json_data);
120 }
121 else {
122 console.error("JSON validation failed:");
123 throw new Error(error!);
124 }
125}
126
127/**
128 * プロジェクトファイルが正しい形式に沿っているか調べる

Callers 2

addFunction · 0.90
initFunction · 0.85

Calls 2

findProjectJSONFunction · 0.85
validateProjectJSONFunction · 0.85

Tested by

no test coverage detected