[
https://issues.apache.org/jira/browse/CB-10519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15148320#comment-15148320
]
ASF GitHub Bot commented on CB-10519:
-------------------------------------
Github user vladimir-kotikov commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/384#discussion_r52985929
--- 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 --
> Why can't we just essentially wrap the entire method in return
`Q().then(function() { ... };`?
We can and basically this would be same. I think it's just a matter of
taste..
If you wish, i can update the PR in the manner you proposed
> 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: [email protected]
For additional commands, e-mail: [email protected]