🐛 update actions work
This commit is contained in:
6
bin/builders/BaseBuilder.ts
vendored
6
bin/builders/BaseBuilder.ts
vendored
@@ -58,15 +58,19 @@ export default abstract class BaseBuilder {
|
||||
? ' --registry=https://registry.npmmirror.com'
|
||||
: '';
|
||||
|
||||
// Windows环境下需要更长的超时时间
|
||||
const timeout = process.platform === 'win32' ? 600000 : 300000;
|
||||
|
||||
if (isChina) {
|
||||
logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
|
||||
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
||||
await fsExtra.copy(projectCnConf, projectConf);
|
||||
await shellExec(
|
||||
`cd "${npmDirectory}" && ${packageManager} install${registryOption}`,
|
||||
timeout,
|
||||
);
|
||||
} else {
|
||||
await shellExec(`cd "${npmDirectory}" && ${packageManager} install`);
|
||||
await shellExec(`cd "${npmDirectory}" && ${packageManager} install`, timeout);
|
||||
}
|
||||
spinner.succeed(chalk.green('Package installed!'));
|
||||
if (!tauriTargetPathExists) {
|
||||
|
||||
10
bin/utils/shell.ts
vendored
10
bin/utils/shell.ts
vendored
@@ -1,17 +1,25 @@
|
||||
import { execa } from 'execa';
|
||||
import { npmDirectory } from './dir';
|
||||
|
||||
export async function shellExec(command: string) {
|
||||
export async function shellExec(command: string, timeout: number = 300000) {
|
||||
try {
|
||||
const { exitCode } = await execa(command, {
|
||||
cwd: npmDirectory,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
timeout,
|
||||
});
|
||||
return exitCode;
|
||||
} catch (error: any) {
|
||||
const exitCode = error.exitCode ?? 'unknown';
|
||||
const errorMessage = error.message || 'Unknown error occurred';
|
||||
|
||||
if (error.timedOut) {
|
||||
throw new Error(
|
||||
`Command timed out after ${timeout}ms: "${command}". Try increasing timeout or check network connectivity.`,
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user