From 52cdd166aadb67441d2b98903914c5d69916d9f6 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 7 Nov 2022 02:24:16 +0800 Subject: [PATCH] core: bug fix --- packages/hydrooj/bin/commands.ts | 1 + packages/hydrooj/src/lib/i18n.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/hydrooj/bin/commands.ts b/packages/hydrooj/bin/commands.ts index ef3dd679c..cfe12e6b3 100644 --- a/packages/hydrooj/bin/commands.ts +++ b/packages/hydrooj/bin/commands.ts @@ -167,6 +167,7 @@ if (!argv.args[0] || argv.args[0] === 'cli') { } else throw new Error(`Unsupported install source: ${src}`); if (!newAddonPath) throw new Error('Addon download failed'); console.log('Installing depedencies'); + if (!fs.existsSync(path.join(newAddonPath, 'package.json'))) throw new Error('Invalid plugin file'); child.execSync('yarn --production', { stdio: 'inherit', cwd: newAddonPath }); child.execSync(`hydrooj addon add '${newAddonPath}'`); fs.writeFileSync(path.join(newAddonPath, '__metadata__'), JSON.stringify({ diff --git a/packages/hydrooj/src/lib/i18n.ts b/packages/hydrooj/src/lib/i18n.ts index bbf26464c..2d9415f94 100644 --- a/packages/hydrooj/src/lib/i18n.ts +++ b/packages/hydrooj/src/lib/i18n.ts @@ -65,7 +65,7 @@ global.Hydro.locales = new Proxy(translations, { get(s, key) { if (typeof key === 'string') return app.i18n.get(key, lang); const result = {}; - for (let i = s.length - 1; i; i--) Object.assign(result, s[i]); + for (let i = s.length - 1; i >= 0; i--) Object.assign(result, s[i]); return result; }, has(s, key: string) {