From de96722d57eb211b02d277791008051710d654ac Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 9 Jun 2021 09:40:08 +0800 Subject: [PATCH] judge: fix user_extra_files --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/judge/default.ts | 4 +++- packages/hydrojudge/src/judge/hack.ts | 8 ++++++-- packages/hydrojudge/src/judge/interactive.ts | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 6b6d396e5..567fcc0c3 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.2", + "version": "2.8.3", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index 4530354ae..e51f3ec9f 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -135,7 +135,9 @@ export const judge = async (ctx) => { for (const file of ctx.config.user_extra_files) { copyIn[parseFilename(file)] = { src: file }; } - return await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + const execute = await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + execute.copyIn = { ...copyIn, ...execute.copyIn }; + return execute; })(), (async () => { if (!ctx.config.checker_type || ctx.config.checker_type === 'default') { diff --git a/packages/hydrojudge/src/judge/hack.ts b/packages/hydrojudge/src/judge/hack.ts index da0992c31..fadb87fbf 100644 --- a/packages/hydrojudge/src/judge/hack.ts +++ b/packages/hydrojudge/src/judge/hack.ts @@ -25,7 +25,9 @@ export const judge = async (ctx) => { for (const file of ctx.config.user_extra_files) { copyIn[parseFilename(file)] = { src: file }; } - return await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + const exec = await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + exec.copyIn = { ...copyIn, ...exec.copyIn }; + return exec; })(), // Validator (async () => { @@ -43,7 +45,9 @@ export const judge = async (ctx) => { copyIn[parseFilename(file)] = { src: file }; } const file = await fs.readFile(ctx.config.std); - return await compile(ctx.getLang(parseFilename(ctx.config.std).split('.')[1]), file.toString(), 'std', copyIn); + const exec = await compile(ctx.getLang(parseFilename(ctx.config.std).split('.')[1]), file.toString(), 'std', copyIn); + exec.copyIn = { ...copyIn, ...exec.copyIn }; + return exec; })(), // Checker (async () => { diff --git a/packages/hydrojudge/src/judge/interactive.ts b/packages/hydrojudge/src/judge/interactive.ts index e211dd705..2007ed5e5 100644 --- a/packages/hydrojudge/src/judge/interactive.ts +++ b/packages/hydrojudge/src/judge/interactive.ts @@ -97,7 +97,9 @@ export const judge = async (ctx) => { for (const file of ctx.config.user_extra_files) { copyIn[parseFilename(file)] = { src: file }; } - return await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + const execute = await compile(ctx.getLang(ctx.lang), ctx.code, 'code', copyIn, ctx.next); + execute.copyIn = { ...copyIn, ...execute.copyIn }; + return execute; })(), (async () => { const copyIn = { 'testlib.h': { src: testlibSrc } };