Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8287

Inconsistent hook execution order between build and run

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.1.3
    • None
    • cordova-lib

    Description

      before/after compile and/or build never fire when running via cordova cli.

      expected behaviour: When running `cordova run <platform>` from the command line, we expect that a compile must occur before running.

      actual behaviour: the compile and build hooks never actually fire, even though the build still happens.

      test case:

      Note about the below gist

      The gist executed below simply populates all of the known hooks in the hooks folder. When a hook is executed it echos "#### HOOK: <hook_name>"

      Note about the sed expression below

      The hooks described above will output a pound sign at the beginning of the line, remove all lines not beginning with a # and any empty lines

      testcase.sh
      #!/bin/bash
      PLATFORM=ios
      
      echo ----- Create a project -----
      cordova create hello-world
      echo ----- Enter the project hooks folder -----
      cd hello-world/hooks
      echo ----- Populate the hooks folder with all known hooks -----
      bash <(curl -s https://gist.githubusercontent.com/jayproulx/214bfa61684a5c5f0cb9/raw/43048b2c5a66783719accabe1f15b1b2cbe159e2/create_hooks.sh)
      echo ----- Return to the project root -----
      cd ..
      echo ----- Add a platform -----
      cordova platform add $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      echo ----- Try building first -----
      cordova build $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      echo ----- Then try running -----
      cordova run $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      echo ----- Clean your platform -----
      cordova platform remove $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      cordova platform add $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      echo ----- Then try running directly -----
      cordova run $PLATFORM -d | sed '/^[^#].*$/d;/^\s*$/d'
      

      output:

      jproulx-mbp-2:tmp jproulx$ ./testcase.sh 
      ----- Create a project -----
      Creating a new cordova project with name "HelloCordova" and id "io.cordova.hellocordova" at location "/Users/jproulx/tmp/hello-world"
      ----- Enter the project hooks folder -----
      ----- Populate the hooks folder with all known hooks -----
      ----- Return to the project root -----
      ----- Add a platform -----
      #### HOOK: before_platform_add
      #### HOOK: before_prepare
      #### HOOK: after_prepare
      #### HOOK: after_platform_add
      ----- Try building first -----
      #### HOOK: before_build
      #### HOOK: before_prepare
      #### HOOK: after_prepare
      #### HOOK: before_compile
      #### HOOK: after_compile
      #### HOOK: after_build
      ----- Then try running -----
      #### HOOK: before_run
      #### HOOK: before_prepare
      #### HOOK: after_prepare
      No device is connected, trying Simulator.
      2015-01-09 15:18:43.103 ios-sim[86821:3288011] stderrPath: /Users/jproulx/tmp/hello-world/platforms/ios/cordova/console.log
      2015-01-09 15:18:43.104 ios-sim[86821:3288011] stdoutPath: /Users/jproulx/tmp/hello-world/platforms/ios/cordova/console.log
      #### HOOK: after_run
      ----- Clean your platform -----
      #### HOOK: before_platform_rm
      #### HOOK: after_platform_rm
      #### HOOK: before_platform_add
      #### HOOK: before_prepare
      #### HOOK: after_prepare
      #### HOOK: after_platform_add
      ----- Then try running directly -----
      #### HOOK: before_run
      #### HOOK: before_prepare
      #### HOOK: after_prepare
      No device is connected, trying Simulator.
      2015-01-09 15:18:54.362 ios-sim[87036:3288601] stderrPath: /Users/jproulx/tmp/hello-world/platforms/ios/cordova/console.log
      2015-01-09 15:18:54.363 ios-sim[87036:3288601] stdoutPath: /Users/jproulx/tmp/hello-world/platforms/ios/cordova/console.log
      #### HOOK: after_run
      

      Note that (before|after)_compile only execute when running `cordova build ios`

      Attachments

        Activity

          People

            Unassigned Unassigned
            jayproulx Jay Proulx
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: