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

refactor: replace superspawn with execa #1190

Merged
merged 1 commit into from
Nov 12, 2021

Conversation

raphinesse
Copy link
Contributor

Motivation and Context

Progresses apache/cordova#16 and apache/cordova#7

Description

Use execa for any subprocess spawning.

A few notes

execa has no equivalent of superspawn's printCommand option (if set to true, it emits a verbose log of the command being executed). In the current state of this PR, those verbose logs are removed without a substitute.

superspawn promises resolve to the captured stdout, while execa resolves to an object with more properties. In many of the cases where we spawn subprocesses, this does not matter, since we we only care about promise fulfillment.

superspawn allowed to subscribe to a running process' output by means of Q's progress method. This basically directly translates to subscribing to data events on the backing streams. So that is what we used to replace these calls. However, the existing code seems to assume that the data emitted are whole lines of output only. This is by no means guaranteed, so we added FIXME comments to the code.

Testing

  • Existing tests pass
  • It would be great if someone could do some manual tests with the platform (I own no Apple computer)

@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2021

Codecov Report

Merging #1190 (b01913e) into master (91d869a) will increase coverage by 0.24%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1190      +/-   ##
==========================================
+ Coverage   74.90%   75.15%   +0.24%     
==========================================
  Files          13       13              
  Lines        1654     1658       +4     
==========================================
+ Hits         1239     1246       +7     
+ Misses        415      412       -3     
Impacted Files Coverage Δ
bin/templates/scripts/cordova/lib/run.js 23.07% <15.38%> (+0.34%) ⬆️
bin/templates/scripts/cordova/lib/Podfile.js 75.12% <22.22%> (+1.91%) ⬆️
bin/templates/scripts/cordova/lib/build.js 44.44% <50.00%> (+0.34%) ⬆️
bin/templates/scripts/cordova/lib/versions.js 89.36% <92.30%> (+0.98%) ⬆️
bin/templates/scripts/cordova/lib/listDevices.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91d869a...b01913e. Read the comment docs.

Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

Code changes LGTM.

I also tested:

  • npm t
  • create
  • platform add ios
  • prepare ios
  • build ios
  • clean ios
    Failed but not related to the spawn/execa migration.

    note: Using new build system
    error: Could not delete /Users/cordova/.test/cordovaTest/platforms/ios/build because it was not created by the build system.
    note: Build preparation complete

    ** CLEAN FAILED **

  • run ios --list
  • run ios

@erisu erisu merged commit 6396343 into apache:master Nov 12, 2021
@raphinesse raphinesse deleted the replace-superspawn branch November 12, 2021 15:42
@raphinesse
Copy link
Contributor Author

Thanks so much for the test!

@erisu erisu added this to the 7.0.0 milestone Nov 16, 2021
gazben pushed a commit to apicore-engineering/cordova-ios that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants