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

Use cross-spawn & shelljs instead of child-process #478

Merged
merged 2 commits into from Dec 18, 2018
Merged

Use cross-spawn & shelljs instead of child-process #478

merged 2 commits into from Dec 18, 2018

Conversation

oliversalzburg
Copy link
Contributor

@oliversalzburg oliversalzburg commented Dec 18, 2018

Platforms affected

iOS

What does this PR do?

Applies superspawn and shelljs consistently. Both modules are used in other places in this module. The existing spawn.js in this project should be obsolete now. I preserved it just in case.

Details by @brodybits:

Change details:

  • Use cross-spawn ("superspawn") instead of child-process spawn
  • Use shelljs instead instead of child-process spawn in other places
  • Add a comment that the spawn function provided by spawn.js is deprecated

Motivation: this change will allow us to spawn with printCommand: true option, to print the xcodebuild and other shell commands as proposed in #479.

What testing has been done on this change?

Nothing at all.

  • Green Travis CI build

@oliversalzburg oliversalzburg changed the title Feature/superspawn Apply shell interaction approaches consistently Dec 18, 2018
Copy link
Member

@dpogue dpogue left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

bin/templates/scripts/cordova/lib/build.js Outdated Show resolved Hide resolved
@@ -27,6 +27,7 @@ var proc = require('child_process');
* @param {String} opt_cwd Working directory for command
* @param {String} opt_verbosity Verbosity level for command stdout output, "verbose" by default
* @return {Promise} Promise either fullfilled or rejected with error code
* @deprecated Use `require('cordova-common').superspawn` instead.
Copy link
Member

Choose a reason for hiding this comment

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

I'd be inclined to just remove this outright in the next major, but I guess technically we don't know if anything else used it so we should go through one major cycle with it marked deprecated 🙁

Copy link

Choose a reason for hiding this comment

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

I also would favor updating spawn.js to output a warning message that it is deprecated and will be removed in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm somewhat resistant to just console.log in this context. If we're assuming that someone is just going to require() this file, we can't assume other logging constructs to be in place. And logging directly to console may be more disturbing than helpful because it might break code that parses console output (which wouldn't be unreasonable with this code).

So I'd rather leave it as is, unless someone has a very specific suggestion on how to approach the issue.

Copy link

Choose a reason for hiding this comment

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

Got it. I would like to raise to finish raising another PR to add the deprecation message, for separate discussion, before we resolving this conversation.

Copy link

@brodycj brodycj left a comment

Choose a reason for hiding this comment

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

  • please fix test failures
  • I would favor updating the title to better explain the actual changes, for example: "Use cordova-common spawn & shelljs to improve xcodebuild log"

@codecov-io
Copy link

codecov-io commented Dec 18, 2018

Codecov Report

Merging #478 into master will increase coverage by 0.3%.
The diff coverage is 20%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #478     +/-   ##
=========================================
+ Coverage    75.4%   75.71%   +0.3%     
=========================================
  Files          12       11      -1     
  Lines        1805     1795     -10     
=========================================
- Hits         1361     1359      -2     
+ Misses        444      436      -8
Impacted Files Coverage Δ
bin/templates/scripts/cordova/lib/build.js 57.71% <20%> (ø) ⬆️
bin/templates/scripts/cordova/lib/run.js 23.36% <20%> (+0.5%) ⬆️

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 2627181...22b7841. Read the comment docs.

Copy link

@brodycj brodycj left a comment

Choose a reason for hiding this comment

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

Thanks @oliversalzburg, issues seem to be resolved now. Are you ready for us to merge this one?

@brodycj brodycj changed the title Apply shell interaction approaches consistently Consistent shell usage to fix xcodebuild log Dec 18, 2018
@oliversalzburg oliversalzburg changed the title Consistent shell usage to fix xcodebuild log Use cordova-common spawn & shelljs to improve xcodebuild log Dec 18, 2018
@oliversalzburg
Copy link
Contributor Author

@brodybits Should be good now. I also adjusted the title per your suggestion. Thanks!

@oliversalzburg
Copy link
Contributor Author

Oh, you just did that also. Sorry. Feel free to change back. I won't touch it again :D

@brodycj
Copy link

brodycj commented Dec 18, 2018

Wonders of interactive editing:)

I made the terser title to get a "squash merge" commit message within 50 characters. I will probably use the terser title in the commit message and leave it up to you what to do with the title.

I just edited the description to add a more descriptive list of the actual changes, which I would like to use in the squash merge commit message. Please feel free to edit as needed.

I will probably merge it in the next 20-30 minutes or so. Thanks again!

@brodycj brodycj changed the title Use cordova-common spawn & shelljs to improve xcodebuild log Use cross-spawn & shelljs instead of child-process Dec 18, 2018
@brodycj
Copy link

brodycj commented Dec 18, 2018

I just updated the title and my comments in the description yet again. I was under the mistaken impression that this PR did actually fix the xcodebuild command log, which is in #479.

I will raise another followup PR to add the warning that the spawn function in spawn.js is deprecated.

Another comment is that I think we should do the same thing on cordova-osx, just raised apache/cordova-osx#81 to track this.

I will probably merge this in 10-20 minutes. Thanks again for the contributions!

@brodycj brodycj merged commit 4694547 into apache:master Dec 18, 2018
@oliversalzburg oliversalzburg deleted the feature/superspawn branch December 18, 2018 22:58
erisu pushed a commit to erisu/cordova-ios that referenced this pull request Jan 16, 2019
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.

4 participants