Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite cordova/requirements to get rid of
Q.allSettled
Behavior of cordova/requirements should remain unchanged.
- Loading branch information
1 parent
eb9aa97
commit af1a1b5
Showing
1 changed file
with
16 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,10 @@ | |
under the License. | ||
*/ | ||
|
||
var cordova_util = require('./util'); | ||
var Q = require('q'); | ||
var CordovaError = require('cordova-common').CordovaError; | ||
var knownPlatforms = require('../platforms/platforms'); | ||
const { object: zipObject } = require('underscore'); | ||
const { preProcessOptions } = require('./util'); | ||
const { CordovaError } = require('cordova-common'); | ||
const knownPlatforms = require('../platforms/platforms'); | ||
|
||
/** | ||
* Runs requirements check against platforms specified in 'platfoms' argument | ||
|
@@ -32,21 +32,18 @@ var knownPlatforms = require('../platforms/platforms'); | |
* requirements check results for each platform. | ||
*/ | ||
module.exports = function check_reqs (platforms) { | ||
return Promise.resolve().then(function () { | ||
var platforms = cordova_util.preProcessOptions(platforms).platforms; // eslint-disable-line no-use-before-define | ||
return Promise.resolve().then(() => { | ||
const normalizedPlatforms = preProcessOptions(platforms).platforms; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
brodybits
Contributor
|
||
|
||
return Q.allSettled(platforms.map(function (platform) { | ||
return knownPlatforms.getPlatformApi(platform).requirements(); | ||
})).then(function (settledChecks) { | ||
var res = {}; | ||
settledChecks.reduce(function (result, settledCheck, idx) { | ||
var platformName = platforms[idx]; | ||
result[platformName] = settledCheck.state === 'fulfilled' ? | ||
settledCheck.value : | ||
new CordovaError(settledCheck.reason); | ||
return result; | ||
}, res); | ||
return res; | ||
}); | ||
return Promise.all( | ||
normalizedPlatforms.map(getPlatformRequirementsOrError) | ||
).then(results => zipObject(normalizedPlatforms, results)); | ||
}); | ||
}; | ||
|
||
function getPlatformRequirementsOrError (platform) { | ||
return knownPlatforms | ||
.getPlatformApi(platform) | ||
.requirements() | ||
.catch(err => new CordovaError(err)); | ||
} |
@raphinesse This line causes an error for me,
this.isCordova is not a function
. The problem is thatpreProcessOptions
assumes it is called ascordova_util.preProcessOptions
, it needs itsthis
to be bound tocordova_util
. But when called as above thethis
is bound toglobal
.