Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not block run-ios/android when failed to start packager #2252

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions packages/cli-tools/src/startServerInNewWindow.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import path from 'path';
import fs from 'fs';
import execa from 'execa';
import {CLIError} from './errors';
import resolveNodeModuleDir from './resolveNodeModuleDir';
import logger from './logger';
import chalk from 'chalk';

const ERROR = `a dev server manually by running ${chalk.bold(
'npm start',
)} or ${chalk.bold('yarn start')} in other terminal window.`;

function startServerInNewWindow(
port: number,
Expand All @@ -12,9 +16,11 @@ function startServerInNewWindow(
terminal?: string,
) {
if (!terminal) {
throw new CLIError(
'Cannot start server in new window because no terminal app was specified.',
logger.error(
'Cannot start server in new windows because no terminal app was specified, use --terminal to specify, or start ' +
ERROR,
);
return;
}

/**
Expand Down Expand Up @@ -73,10 +79,12 @@ function startServerInNewWindow(
);
}
} catch (error) {
return new CLIError(
`Couldn't copy the script for running bundler. Please check if the "${scriptFile}" file exists in the "node_modules/@react-native-community/cli-tools" folder and try again.`,
logger.error(
`Couldn't copy the script for running bundler. Please check if the "${scriptFile}" file exists in the "node_modules/@react-native-community/cli-tools" folder, or start ` +
ERROR,
error as any,
);
return;
}

if (process.platform === 'darwin') {
Expand Down Expand Up @@ -109,8 +117,10 @@ function startServerInNewWindow(
stdio: 'ignore',
});
}

logger.error(
`Cannot start the packager. Unknown platform ${process.platform}`,
`Cannot start the packager. Unknown platform ${process.platform}. Try starting ` +
ERROR,
);
return;
}
Expand Down