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: CLI breaks process when pod install has not failed #3943

Merged
merged 4 commits into from
Sep 27, 2018

Conversation

rosen-vladimirov
Copy link
Contributor

First commit:

refactor: move executePodInstall method to CocoapodsService

The CocoapodsService is designed to execute all pod related operations, so move the executePodInstall method from IosProjectService to CocoapodsService.

fix: CLI breaks process when pod install has not failed

The fix and related unit tests are in the second commit:
In some cases pod install command prints data on the stderr (for example when setup the repo for the first time or when updating it). CLI detects the data on stderr and fails the operation. However these are not real errors.
Fix this by passing { throwError: false } to spawnFromEvent method. This way it will not fail in any case. Check the exit code of the operation and if it is not 0, just fail.
Pipe the stderr of the pod install process to stdout of CLI, this way we'll not polute CLI's stderr with some unrelevant info.
NOTE: pod install command prints the real errors on stdout, not stderr.

PR Checklist

What is the current behavior?

When pod install method prints some information on stderr (for example when this is the first execution of the command, it setups the master repo and prints progress indicator on stderr), CLI process stops with error pod install failed....

What is the new behavior?

CLI continues the execution in the mentioned scenario. CLI will stop only when pod install command exits with non-zero exit code.

Fixes issue #3686

this.$errors.failWithoutHelp("CocoaPods or ruby gem 'xcodeproj' is not installed. Run `sudo gem install cocoapods` and try again.");
}

await this.$xcprojService.verifyXcproj(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean variable passed as param 🙀 🙀 🙀 😶

await this.prepareCocoapods(pluginPlatformsFolderPath, pluginData, projectData);

const projectRoot = this.getPlatformData(projectData).projectRoot;
await this.$cocoapodsService.applyPluginPodfileToProject(pluginData, projectData, projectRoot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was included in prepareCocoapods method

if (opts && opts.executePodInstall && this.$fs.exists(pluginPodFilePath)) {	
			await this.executePodInstall(projectData);	
		}

but I can't see to call it in the new implementation. Maybe I'm missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opts were never passed, so I just removed this code

The CocoapodsService is designed to execute all pod related operations, so move the `executePodInstall` method from `IosProjectService` to `CocoapodsService`.
In some cases `pod install` command prints data on the `stderr` (for example when setup the repo for the first time or when updating it). CLI detects the data on stderr and fails the operation. However these are not real errors.
Fix this by passing `{ throwError: false }` to `spawnFromEvent` method. This way it will not fail in any case. Check the exit code of the operation and if it is not 0, just fail.
Pipe the stderr of the `pod install` process to stdout of CLI, this way we'll not polute CLI's stderr with some unrelevant info.
NOTE: `pod install` command prints the real errors on stdout, not stderr.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/cocoapods-errors-parsing branch from a970cbe to 2db98d0 Compare September 27, 2018 11:21
@rosen-vladimirov rosen-vladimirov merged commit c61f101 into master Sep 27, 2018
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/cocoapods-errors-parsing branch September 27, 2018 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants