fix stdout pipe buffer blocking during package installation
This commit is contained in:
6
bin/builders/BaseBuilder.ts
vendored
6
bin/builders/BaseBuilder.ts
vendored
@@ -120,15 +120,17 @@ export default abstract class BaseBuilder {
|
|||||||
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
||||||
await fsExtra.copy(projectCnConf, projectConf);
|
await fsExtra.copy(projectCnConf, projectConf);
|
||||||
await shellExec(
|
await shellExec(
|
||||||
`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption} --silent`,
|
`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`,
|
||||||
timeout,
|
timeout,
|
||||||
buildEnv,
|
buildEnv,
|
||||||
|
this.options.debug,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await shellExec(
|
await shellExec(
|
||||||
`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption} --silent`,
|
`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`,
|
||||||
timeout,
|
timeout,
|
||||||
buildEnv,
|
buildEnv,
|
||||||
|
this.options.debug,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
spinner.succeed(chalk.green('Package installed!'));
|
spinner.succeed(chalk.green('Package installed!'));
|
||||||
|
|||||||
3
bin/helpers/rust.ts
vendored
3
bin/helpers/rust.ts
vendored
@@ -81,6 +81,9 @@ export async function installRust() {
|
|||||||
try {
|
try {
|
||||||
await shellExec(
|
await shellExec(
|
||||||
IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac,
|
IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac,
|
||||||
|
300000,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
spinner.succeed(chalk.green('✔ Rust installed successfully!'));
|
spinner.succeed(chalk.green('✔ Rust installed successfully!'));
|
||||||
ensureRustEnv();
|
ensureRustEnv();
|
||||||
|
|||||||
3
bin/utils/shell.ts
vendored
3
bin/utils/shell.ts
vendored
@@ -5,11 +5,12 @@ export async function shellExec(
|
|||||||
command: string,
|
command: string,
|
||||||
timeout: number = 300000,
|
timeout: number = 300000,
|
||||||
env?: Record<string, string>,
|
env?: Record<string, string>,
|
||||||
|
showOutput: boolean = false,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const { exitCode } = await execa(command, {
|
const { exitCode } = await execa(command, {
|
||||||
cwd: npmDirectory,
|
cwd: npmDirectory,
|
||||||
stdio: ['inherit', 'pipe', 'inherit'], // Hide stdout verbose, keep stderr
|
stdio: showOutput ? 'inherit' : ['inherit', 'pipe', 'inherit'],
|
||||||
shell: true,
|
shell: true,
|
||||||
timeout,
|
timeout,
|
||||||
env: env ? { ...process.env, ...env } : process.env,
|
env: env ? { ...process.env, ...env } : process.env,
|
||||||
|
|||||||
10
dist/cli.js
vendored
10
dist/cli.js
vendored
@@ -201,11 +201,11 @@ const IS_MAC = platform$1 === 'darwin';
|
|||||||
const IS_WIN = platform$1 === 'win32';
|
const IS_WIN = platform$1 === 'win32';
|
||||||
const IS_LINUX = platform$1 === 'linux';
|
const IS_LINUX = platform$1 === 'linux';
|
||||||
|
|
||||||
async function shellExec(command, timeout = 300000, env) {
|
async function shellExec(command, timeout = 300000, env, showOutput = false) {
|
||||||
try {
|
try {
|
||||||
const { exitCode } = await execa(command, {
|
const { exitCode } = await execa(command, {
|
||||||
cwd: npmDirectory,
|
cwd: npmDirectory,
|
||||||
stdio: ['inherit', 'pipe', 'inherit'], // Hide stdout verbose, keep stderr
|
stdio: showOutput ? 'inherit' : ['inherit', 'pipe', 'inherit'],
|
||||||
shell: true,
|
shell: true,
|
||||||
timeout,
|
timeout,
|
||||||
env: env ? { ...process.env, ...env } : process.env,
|
env: env ? { ...process.env, ...env } : process.env,
|
||||||
@@ -340,7 +340,7 @@ async function installRust() {
|
|||||||
const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup';
|
const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup';
|
||||||
const spinner = getSpinner('Downloading Rust...');
|
const spinner = getSpinner('Downloading Rust...');
|
||||||
try {
|
try {
|
||||||
await shellExec(IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac);
|
await shellExec(IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac, 300000, undefined, true);
|
||||||
spinner.succeed(chalk.green('✔ Rust installed successfully!'));
|
spinner.succeed(chalk.green('✔ Rust installed successfully!'));
|
||||||
ensureRustEnv();
|
ensureRustEnv();
|
||||||
}
|
}
|
||||||
@@ -756,10 +756,10 @@ class BaseBuilder {
|
|||||||
logger.info(`✺ Located in China, using ${packageManager}/rsProxy CN mirror.`);
|
logger.info(`✺ Located in China, using ${packageManager}/rsProxy CN mirror.`);
|
||||||
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
|
||||||
await fsExtra.copy(projectCnConf, projectConf);
|
await fsExtra.copy(projectCnConf, projectConf);
|
||||||
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption} --silent`, timeout, buildEnv);
|
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`, timeout, buildEnv, this.options.debug);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption} --silent`, timeout, buildEnv);
|
await shellExec(`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`, timeout, buildEnv, this.options.debug);
|
||||||
}
|
}
|
||||||
spinner.succeed(chalk.green('Package installed!'));
|
spinner.succeed(chalk.green('Package installed!'));
|
||||||
if (!tauriTargetPathExists) {
|
if (!tauriTargetPathExists) {
|
||||||
|
|||||||
Reference in New Issue
Block a user