[ 
https://issues.apache.org/jira/browse/CB-13581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16509095#comment-16509095
 ] 

ASF GitHub Bot commented on CB-13581:
-------------------------------------

knight9999 opened a new pull request #366: CB-13581 open ios simulator by using 
child_process
URL: https://github.com/apache/cordova-ios/pull/366
 
 
   <!--
   Please make sure the checklist boxes are all checked before submitting the 
PR. The checklist
   is intended as a quick reference, for complete details please see our 
Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Platforms affected
   
   cordova-ios
   
   ### What does this PR do?
   
   The command `cordova run ios --simulator` does not finish properly.
   Because bin/templates/scripts/cordova/lib/run.js opens ios simulator by 
calling
   ```
   iossim.launch(appPath, 'com.apple.CoreSimulator.SimDeviceType.' + target, 
logPath, '--exit');
   ```
   Dut to the last argument `--exit`, ios-sim module will call 
`process.exit(0);` in ios-sim/src/lib.js.
   Then the cordova command itself stops. 
   
   This PR improves the issue.
   By using child_process, the cordova command does not stop when ios-sim calls 
`process.exit(0)`.
   
   ### What testing has been done on this change?
   
   Here is sample plugin. 
https://github.com/knight9999/cordova-plugin-promise-sample .
   This plugin has a `after run` plugin hook.
   This plugin shows following messages after the command `cordova run ios 
--emulator`.
   ```
   --- start run ---
   --- now count = 0 ---
   --- now count = 1 ---
   --- now count = 2 ---
   --- now count = 3 ---
   --- now count = 4 ---
   --- now count = 5 ---
   --- now count = 6 ---
   --- now count = 7 ---
   --- now count = 8 ---
   --- now count = 9 ---
   ```
   Before applying this PR, only the first message is shown. Because the 
cordova command stops due to the `process.exit(0)`.
   After applying this PR,  the plugin works well.
   
   
   ### Checklist
   - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) 
in the JIRA database
   - [x] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform 
affected.
   - [x] Added automated test coverage as appropriate for this change.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Cordova plugin after_run hook terminates before promise is resolved
> -------------------------------------------------------------------
>
>                 Key: CB-13581
>                 URL: https://issues.apache.org/jira/browse/CB-13581
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-cli, cordova-plugins
>    Affects Versions: 7.0.0
>         Environment: Running Cordova 7.1.0 on macOS Sierra 10.12.6
>            Reporter: Niklas Kirk Mouritzsen
>            Priority: Blocker
>              Labels: hooks, plugin
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> When creating a plugin that hooks itself up on the after_run hook, its is 
> terminated before the promise is resolved or rejected. It is currently 
> blocking our development. I've created this post on stack overflow describing 
> the problem in greater detail:
> https://stackoverflow.com/questions/47288569/cordova-plugin-asynchronous-hooks-not-working
> Let me know if I can provide any additional insight in the problem, or if 
> there are any known workarounds/fixes for this.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to