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

Ken Naito commented on CB-13581:
--------------------------------

Thanks Niklas,

I have confirmed this issue.
I found that the 'cordova run ios' command has finished after launching 
simulator.
Therefore all scripts including hook script stop.

To resolve this issue, update platforms/ios/cordova/lib/run.js file as follows,

before:
{code}
function startSim (appPath, target) {
    var logPath = path.join(cordovaPath, 'console.log');

    return iossim.launch(appPath, 'com.apple.CoreSimulator.SimDeviceType.' + 
target, logPath, '--exit');
}
{code}

after:
{code}
function startSim (appPath, target) {
    var logPath = path.join(cordovaPath, 'console.log');

    return iossimLaunch(appPath, 'com.apple.CoreSimulator.SimDeviceType.' + 
target, logPath, '--exit');
}

var cp = require('child_process');

function iossimLaunch (app_path, devicetypeid, log, exit) {
  var f = path.resolve(path.dirname(require.resolve('ios-sim')), 'bin', 
'ios-sim');
  var proc = cp.spawn(f, ['launch', app_path, '--devicetypeid', devicetypeid,
                                    '--log', log, exit]);
  proc.stdout.on('data', (data) => {
      console.log(data.toString());
  });
  return ;
}
{code}

I will create PR for this.


> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to