Skip to content

Commit dfbb193

Browse files
authored
feat: make run-ios output leaner (#472)
* feat: make run-ios output leaner * --ammend
1 parent 653db76 commit dfbb193

File tree

1 file changed

+35
-21
lines changed
  • packages/platform-ios/src/commands/runIOS

1 file changed

+35
-21
lines changed

packages/platform-ios/src/commands/runIOS/index.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ function runIOS(_: Array<string>, ctx: ConfigT, args: FlagsT) {
6060
const scheme = args.scheme || inferredSchemeName;
6161

6262
logger.info(
63-
`Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} ${
64-
xcodeProject.name
65-
}`,
63+
`Found Xcode ${
64+
xcodeProject.isWorkspace ? 'workspace' : 'project'
65+
} "${chalk.bold(xcodeProject.name)}"`,
6666
);
6767

6868
const {device, udid} = args;
@@ -161,14 +161,12 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) {
161161

162162
const appPath = getBuildPath(args.configuration, appName, false, scheme);
163163

164-
logger.info(`Installing ${appPath}`);
164+
logger.info(`Installing "${chalk.bold(appPath)}"`);
165165

166166
child_process.spawnSync(
167167
'xcrun',
168168
['simctl', 'install', selectedSimulator.udid, appPath],
169-
{
170-
stdio: 'inherit',
171-
},
169+
{stdio: 'inherit'},
172170
);
173171

174172
const bundleID = child_process
@@ -180,15 +178,20 @@ async function runOnSimulator(xcodeProject, scheme, args: FlagsT) {
180178
// $FlowExpectedError https://github.com/facebook/flow/issues/5675
181179
.trim();
182180

183-
logger.info(`Launching ${bundleID}`);
181+
logger.info(`Launching "${chalk.bold(bundleID)}"`);
184182

185-
child_process.spawnSync(
186-
'xcrun',
187-
['simctl', 'launch', selectedSimulator.udid, bundleID],
188-
{
189-
stdio: 'inherit',
190-
},
191-
);
183+
const result = child_process.spawnSync('xcrun', [
184+
'simctl',
185+
'launch',
186+
selectedSimulator.udid,
187+
bundleID,
188+
]);
189+
190+
if (result.status === 0) {
191+
logger.success('Successfully launched the app on the simulator');
192+
} else {
193+
logger.error('Failed to launch the app on simulator', result.stderr);
194+
}
192195
}
193196

194197
async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) {
@@ -221,7 +224,7 @@ async function runOnDevice(selectedDevice, scheme, xcodeProject, args: FlagsT) {
221224
'--justlaunch',
222225
];
223226

224-
logger.info(`Installing and launching your app on ${selectedDevice.name}...`);
227+
logger.info(`Installing and launching your app on ${selectedDevice.name}`);
225228

226229
const iosDeployOutput = child_process.spawnSync(
227230
'ios-deploy',
@@ -254,7 +257,11 @@ function buildProject(xcodeProject, udid, scheme, args: FlagsT) {
254257
'-derivedDataPath',
255258
`build/${scheme}`,
256259
];
257-
logger.info(`Building using "xcodebuild ${xcodebuildArgs.join(' ')}"`);
260+
logger.info(
261+
`Building ${chalk.dim(
262+
`(using "xcodebuild ${xcodebuildArgs.join(' ')}")`,
263+
)}`,
264+
);
258265
let xcpretty;
259266
if (!args.verbose) {
260267
xcpretty =
@@ -271,11 +278,16 @@ function buildProject(xcodeProject, udid, scheme, args: FlagsT) {
271278
let buildOutput = '';
272279
let errorOutput = '';
273280
buildProcess.stdout.on('data', data => {
274-
buildOutput += data.toString();
281+
const stringData = data.toString();
282+
buildOutput += stringData;
275283
if (xcpretty) {
276284
xcpretty.stdin.write(data);
277285
} else {
278-
logger.info(data.toString());
286+
if (logger.isVerbose()) {
287+
logger.debug(stringData);
288+
} else {
289+
process.stdout.write('.');
290+
}
279291
}
280292
});
281293
buildProcess.stderr.on('data', data => {
@@ -284,6 +296,8 @@ function buildProject(xcodeProject, udid, scheme, args: FlagsT) {
284296
buildProcess.on('close', code => {
285297
if (xcpretty) {
286298
xcpretty.stdin.end();
299+
} else {
300+
process.stdout.write('\n');
287301
}
288302
if (code !== 0) {
289303
reject(
@@ -295,7 +309,7 @@ function buildProject(xcodeProject, udid, scheme, args: FlagsT) {
295309
logs further, consider building your app with Xcode.app, by opening
296310
${xcodeProject.name}.
297311
`,
298-
errorOutput,
312+
buildOutput + '\n' + errorOutput,
299313
),
300314
);
301315
return;
@@ -307,7 +321,7 @@ function buildProject(xcodeProject, udid, scheme, args: FlagsT) {
307321

308322
function bootSimulator(selectedSimulator) {
309323
const simulatorFullName = formattedDeviceName(selectedSimulator);
310-
logger.info(`Launching ${simulatorFullName}...`);
324+
logger.info(`Launching ${simulatorFullName}`);
311325
try {
312326
child_process.spawnSync('xcrun', [
313327
'instruments',

0 commit comments

Comments
 (0)