install: add timeout to update from yarnpkg

This commit is contained in:
undefined committed 2022-10-31 16:35:44 +08:00
1 parent 7d6b1f3bbc
commit 080f92ae74
1 file changed
+8 -7
+8 -7
View File
@@ -242,23 +242,24 @@ connect-timeout = 10`);
init: 'install.hydro', init: 'install.hydro',
operations: [ operations: [
() => removeOptionalEsbuildDeps(), () => removeOptionalEsbuildDeps(),
() => { (CN ? () => {
if (!CN) return; let res: any = null;
try { try {
exec('yarn config set registry https://registry.npmmirror.com/', { stdio: 'inherit' }); exec('yarn config set registry https://registry.npmmirror.com/', { stdio: 'inherit' });
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { stdio: 'inherit' }); res = exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { stdio: 'inherit' });
} catch (e) { } catch (e) {
console.log('Failed to install from npmmirror, fallback to yarnpkg'); console.log('Failed to install from npmmirror, fallback to yarnpkg');
} finally { } finally {
exec('yarn config set registry https://registry.yarnpkg.com', { stdio: 'inherit' }); exec('yarn config set registry https://registry.yarnpkg.com', { stdio: 'inherit' });
} }
try { try {
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge'); exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { timeout: 60000 });
} catch (e) { } catch (e) {
console.log('Failed to check update from yarnpkg'); console.warn('Failed to check update from yarnpkg');
if (res?.code !== 0) return 'retry';
} }
}, return null;
['yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { retry: true }], } : ['yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { retry: true }]),
() => writeFileSync(`${process.env.HOME}/.hydro/addon.json`, '["@hydrooj/ui-default","@hydrooj/hydrojudge"]'), () => writeFileSync(`${process.env.HOME}/.hydro/addon.json`, '["@hydrooj/ui-default","@hydrooj/hydrojudge"]'),
() => rollbackResolveField(), () => rollbackResolveField(),
], ],