(data: ContestProject, directory_path?: string)
| 111 | * @param directory_path 省略した場合は自動的にプロジェクトディレクトリを探してプロジェクトファイルを上書きする |
| 112 | */ |
| 113 | export 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 | * プロジェクトファイルが正しい形式に沿っているか調べる |
no test coverage detected