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

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

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

    https://github.com/apache/cordova-lib/pull/384#discussion_r52984062
  
    --- 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 --
    
    Hey @vladimir-kotikov - what's the purpose of using `spread()` here (and 
elsewhere)? Why can't we just essentially wrap the entire method in `return 
Q().then(function() { ... };`?


> Using cordova.raw API outside of cordova project results in uncaught 
> exception instead or promise rejection
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: CB-10519
>                 URL: https://issues.apache.org/jira/browse/CB-10519
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>    Affects Versions: 6.0.0
>            Reporter: Vladimir Kotikov
>            Assignee: Vladimir Kotikov
>              Labels: triaged
>
> When trying to {{cordova.raw.platfom('add', ...)}} outside of cordova project 
> the following error message logged to console:
> > Error: Current working directory is not a Cordova-based project.
> However, the error callback for {{cordova.raw.platfom('add', ...)}} isn't 
> called at all.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to