Github user omefire commented on a diff in the pull request: https://github.com/apache/cordova-cli/pull/247#discussion_r62894363 --- Diff: src/cli.js --- @@ -235,41 +317,58 @@ function cli(inputArgs) { throw new CordovaError(msg); } - cordova.raw[cmd].call(null, opts.platforms) - .then(function (platformChecks) { + var result = cordova.raw[cmd].call(null, opts.platforms) + .then(function(platformChecks) { - var someChecksFailed = Object.keys(platformChecks).map(function (platformName) { - events.emit('log', '\nRequirements check results for ' + platformName + ':'); - var platformCheck = platformChecks[platformName]; - if (platformCheck instanceof CordovaError) { - events.emit('warn', 'Check failed for ' + platformName + ' due to ' + platformCheck); - return true; - } - - var someChecksFailed = false; - platformCheck.forEach(function (checkItem) { - var checkSummary = checkItem.name + ': ' + - (checkItem.installed ? 'installed ' : 'not installed ') + - (checkItem.metadata.version || ''); - events.emit('log', checkSummary); - if (!checkItem.installed) { - someChecksFailed = true; - events.emit('warn', checkItem.metadata.reason); + var someChecksFailed = Object.keys(platformChecks).map(function(platformName) { + events.emit('log', '\nRequirements check results for ' + platformName + ':'); + var platformCheck = platformChecks[platformName]; + if (platformCheck instanceof CordovaError) { + events.emit('warn', 'Check failed for ' + platformName + ' due to ' + platformCheck); + return true; } + + var someChecksFailed = false; + platformCheck.forEach(function(checkItem) { + var checkSummary = checkItem.name + ': ' + + (checkItem.installed ? 'installed ' : 'not installed ') + + (checkItem.metadata.version || ''); + events.emit('log', checkSummary); + if (!checkItem.installed) { + someChecksFailed = true; + events.emit('warn', checkItem.metadata.reason); + } + }); + + return someChecksFailed; + }).some(function(isCheckFailedForPlatform) { + return isCheckFailedForPlatform; }); - return someChecksFailed; - }).some(function (isCheckFailedForPlatform) { - return isCheckFailedForPlatform; + if (someChecksFailed) throw new CordovaError('Some of requirements check failed'); }); - - if (someChecksFailed) throw new CordovaError('Some of requirements check failed'); - }).done(); + return result.finally(function() { + if (shouldCollectTelemetry) { + telemetry.track(cmd, result.isFulfilled() ? 'successful' : 'unsuccessful'); + } + return result; + }); } else if (cmd == 'serve') { var port = undashed[1]; - cordova.raw.serve(port).done(); + var result = cordova.raw.serve(port); + return result.finally(function() { + if(shouldCollectTelemetry) { + telemetry.track(cmd, result.isFulfilled() ? 'successful' : 'unsuccessful'); + } + }); } else if (cmd == 'create') { - create(); + var result = create(); + return result.finally(function() { + if (shouldCollectTelemetry) { --- End diff -- As discussed offline, I'm going ahead with this refactoring. but it will require retesting the whole CLI as it affects everything. Looking at things from the benefits/costs perspective, I'm not sure if that's the best route, but ...
--- 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