Github user TimBarham commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/384#discussion_r52993992
  
    --- Diff: cordova-lib/src/cordova/build.js ---
    @@ -17,22 +17,26 @@
         under the License.
     */
     
    -var cordovaUtil      = require('./util'),
    -    HooksRunner           = require('../hooks/HooksRunner');
    +var Q = require('q'),
    +    cordovaUtil = require('./util'),
    +    HooksRunner = require('../hooks/HooksRunner');
     
     // Returns a promise.
     module.exports = function build(options) {
    -    var projectRoot = cordovaUtil.cdProjectRoot();
    -    options = cordovaUtil.preProcessOptions(options);
    -
    -    // fire build hooks
    -    var hooksRunner = new HooksRunner(projectRoot);
    -    return hooksRunner.fire('before_build', options)
    -    .then(function() {
    -        return require('./cordova').raw.prepare(options);
    -    }).then(function() {
    -        return require('./cordova').raw.compile(options);
    -    }).then(function() {
    -        return hooksRunner.fire('after_build', options);
    +    return Q().then(function() {
    +        var opts = cordovaUtil.preProcessOptions(options);
    +        var projectRoot = cordovaUtil.cdProjectRoot();
    +        return [new HooksRunner(projectRoot), opts];
    +    })
    +    .spread(function (hooksRunner, options) {
    --- End diff --
    
    Well, that'd be my preference, as the code ends up much simpler and easy to 
read, to my mind. Otherwise we're arbitrarily splitting out the synchronous 
part of the process into its own separate promise, when there's no need to. But 
ultimately it's up to you :smile:.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to