diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index e759c152e..ad9686d78 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.8.9", + "version": "2.8.10", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/compile.ts b/packages/hydrojudge/src/compile.ts index 894d0b988..404fb1ca8 100644 --- a/packages/hydrojudge/src/compile.ts +++ b/packages/hydrojudge/src/compile.ts @@ -9,9 +9,8 @@ export = async function compile( lang: LangConfig, code: string, target: string, copyIn: any = {}, next?: Function, ): Promise { target = lang.target || target; - const f = {}; + copyIn[lang.code_file] = { content: code }; if (lang.compile) { - copyIn[lang.code_file] = { content: code }; const { status, stdout, stderr, fileIds, } = await run( @@ -21,13 +20,14 @@ export = async function compile( if (status !== STATUS.STATUS_ACCEPTED) throw new CompileError({ status, stdout, stderr }); if (!fileIds[target]) throw new CompileError({ stderr: 'Executable file not found.' }); if (next) next({ compiler_text: compilerText(stdout, stderr) }); - f[target] = { fileId: fileIds[target] }; return { - execute: lang.execute, copyIn: { ...copyIn, ...f }, clean: () => del(fileIds[target]), time: lang.time_limit_rate || 1, + execute: lang.execute, + copyIn: { ...copyIn, [target]: { fileId: fileIds[target] } }, + clean: () => del(fileIds[target]), + time: lang.time_limit_rate || 1, }; } - f[target] = { content: code }; return { - execute: lang.execute, copyIn: { ...copyIn, ...f }, clean: () => Promise.resolve(null), time: lang.time_limit_rate || 1, + execute: lang.execute, copyIn, clean: () => Promise.resolve(null), time: lang.time_limit_rate || 1, }; };