Make download steps easier to follow and modify.
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/48c999eb Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/48c999eb Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/48c999eb Branch: refs/heads/develop Commit: 48c999eb73778d69f1236cec8cae8632019a8566 Parents: 490f910 Author: OmPrakash Muppirala <[email protected]> Authored: Sun Nov 29 02:19:02 2015 -0800 Committer: OmPrakash Muppirala <[email protected]> Committed: Sun Mar 13 00:44:04 2016 -0800 ---------------------------------------------------------------------- npm-flexjs/download_dependencies.js | 63 ++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/48c999eb/npm-flexjs/download_dependencies.js ---------------------------------------------------------------------- diff --git a/npm-flexjs/download_dependencies.js b/npm-flexjs/download_dependencies.js index d2cb82e..87a2469 100644 --- a/npm-flexjs/download_dependencies.js +++ b/npm-flexjs/download_dependencies.js @@ -27,6 +27,20 @@ var apacheFlexJS = require('./dependencies/ApacheFlexJS'); var apacheFalcon = require('./dependencies/ApacheFalcon'); var swfObject = require('./dependencies/SWFObject'); +var installSteps = [ + createDownloadsDirectory, + installFlashPlayerGlobal, + installAdobeAIR, + installApacheFlexJS, + installApacheFalcon, + installSWFObject]; +var currentStep = 0; + +function start() +{ + installSteps[0].call(); +} + function createDownloadsDirectory() { //Create downloads directory if it does not exist already @@ -38,42 +52,59 @@ function createDownloadsDirectory() { if ( e.code != 'EEXIST' ) throw e; } + handleInstallStepComplete(); +} + + +function handleInstallStepComplete(event) +{ + currentStep += 1; + if(currentStep >= installSteps.length) + { + allDownloadsComplete(); + } + else + { + if(installSteps[currentStep] != undefined) + { + installSteps[currentStep].call(); + } + } } -function handleFlashPlayerGlobalComplete(event) +function installFlashPlayerGlobal() { - adobeair.on('complete', handleAdobeAIRComplete); + flashplayerglobal.on('complete', handleInstallStepComplete); + flashplayerglobal.install(); +} + +function installAdobeAIR(event) +{ + adobeair.on('complete', handleInstallStepComplete); adobeair.install(); } -function handleAdobeAIRComplete(event) +function installApacheFlexJS(event) { - apacheFlexJS.on('complete', handleApacheFlexJSComplete); + apacheFlexJS.on('complete', handleInstallStepComplete); apacheFlexJS.install(); } -function handleApacheFlexJSComplete(event) +function installApacheFalcon(event) { - apacheFalcon.on('complete', handleApacheFalconComplete); + apacheFalcon.on('complete', handleInstallStepComplete); apacheFalcon.install(); } -function handleApacheFalconComplete(event) +function installSWFObject(event) { - swfObject.on('complete', handleSwfObjectComplete); + swfObject.on('complete', handleInstallStepComplete); swfObject.install(); } -function handleSwfObjectComplete(event) -{ - allDownloadsComplete(); -} - function allDownloadsComplete() { console.log('Completed all downloads'); } -createDownloadsDirectory(); -flashplayerglobal.on('complete', handleFlashPlayerGlobalComplete); -flashplayerglobal.install(); \ No newline at end of file +start();
