src/cordova/prepare.js
function preparePlatforms (platformList, projectRoot, options) {
    return Q.all(platformList.map(function(platform) {
        // TODO: this need to be replaced by real projectInfo
        // instance for current project.
        var project = {
            root: projectRoot,
            projectConfig: new ConfigParser(cordova_util.projectConfig(projectRoot)),
            locations: {
                plugins: path.join(projectRoot, 'plugins'),
                www: cordova_util.projectWww(projectRoot)
            }
        };

        // CB-9987 We need to reinstall the plugins for the platform it they were added by cordova@<5.4.0
        return restoreMissingPluginsForPlatform(platform, projectRoot, options)
        .then(function () {
            // platformApi prepare takes care of all functionality
            // which previously had been executed by cordova.prepare:
            //   - reset config.xml and then merge changes from project's one,
            //   - update www directory from project's one and merge assets from platform_www,
            //   - reapply config changes, made by plugins,
            //   - update platform's project
            // Please note that plugins' changes, such as installed js files, assets and
            // config changes is not being reinstalled on each prepare.
            var platformApi = platforms.getPlatformApi(platform);
            return platformApi.prepare(project, _.clone(options))
            .then(function () {
                if (platform === 'windows' && !(platformApi instanceof PlatformApiPoly)) {
                    // Windows Api doesn't fire 'pre_package' hook, so we fire it here
                    return new HooksRunner(projectRoot).fire('pre_package', {
                        wwwPath: platformApi.getPlatformInfo().locations.www,
                        platforms: ['windows'],
                        nohooks: options.nohooks
                    });
                }
            })
            .then(function () {
                if (options.browserify) {
                    var browserify = require('../plugman/browserify');
                    return browserify(project, platformApi);
                }
            })
            .then(function () {
                // Handle edit-config in config.xml
                var platformRoot = path.join(projectRoot, 'platforms', platform);
                var platformJson = PlatformJson.load(platformRoot, platform);
                var munger = new PlatformMunger(platform, platformRoot, platformJson);
                munger.add_config_changes(project.projectConfig, /*should_increment=*/true).save_all();
            });
        });
    }));
}
function preparePlatforms (platformList, projectRoot, options) {
    return Q.all(platformList.map(function(platform) {
        // TODO: this need to be replaced by real projectInfo
        // instance for current project.
        var project = {
            root: projectRoot,
            projectConfig: new ConfigParser(cordova_util.projectConfig(projectRoot)),
            locations: {
                plugins: path.join(projectRoot, 'plugins'),
                www: cordova_util.projectWww(projectRoot)
            }
        };

        // CB-9987 We need to reinstall the plugins for the platform it they were added by cordova@<5.4.0
        return restoreMissingPluginsForPlatform(platform, projectRoot, options)
        .then(function () {
            // platformApi prepare takes care of all functionality
            // which previously had been executed by cordova.prepare:
            //   - reset config.xml and then merge changes from project's one,
            //   - update www directory from project's one and merge assets from platform_www,
            //   - reapply config changes, made by plugins,
            //   - update platform's project
            // Please note that plugins' changes, such as installed js files, assets and
            // config changes is not being reinstalled on each prepare.
            var platformApi = platforms.getPlatformApi(platform);
            return platformApi.prepare(project, _.clone(options))
            .then(function () {
                if (platform === 'windows' && !(platformApi instanceof PlatformApiPoly)) {
                    // Windows Api doesn't fire 'pre_package' hook, so we fire it here
                    return new HooksRunner(projectRoot).fire('pre_package', {
                        wwwPath: platformApi.getPlatformInfo().locations.www,
                        platforms: ['windows'],
                        nohooks: options.nohooks
                    });
                }
            })
            .then(function () {
                if (options.browserify) {
                    var browserify = require('../plugman/browserify');
                    return browserify(project, platformApi);
                }
            })
            .then(function () {
                // Handle edit-config in config.xml
                var platformRoot = path.join(projectRoot, 'platforms', platform);
                var platformJson = PlatformJson.load(platformRoot, platform);
                var munger = new PlatformMunger(platform, platformRoot, platformJson);
                munger.add_config_changes(project.projectConfig, /*should_increment=*/true).save_all();
            });
        });
    }));
}
function preparePlatforms ( platformList , projectRoot , options ) { return Q . all ( platformList . map ( function ( platform ) { // TODO: this need to be replaced by real projectInfo // instance for current project. var project = { root : projectRoot , projectConfig : new ConfigParser ( cordova_util . projectConfig ( projectRoot ) ) , locations : { plugins : path . join ( projectRoot , 'plugins' ) , www : cordova_util . projectWww ( projectRoot ) } } ; // CB-9987 We need to reinstall the plugins for the platform it they were added by cordova@<5.4.0 return restoreMissingPluginsForPlatform ( platform , projectRoot , options ) . then ( function ( ) { // platformApi prepare takes care of all functionality // which previously had been executed by cordova.prepare: //   - reset config.xml and then merge changes from project's one, //   - update www directory from project's one and merge assets from platform_www, //   - reapply config changes, made by plugins, //   - update platform's project // Please note that plugins' changes, such as installed js files, assets and // config changes is not being reinstalled on each prepare. var platformApi = platforms . getPlatformApi ( platform ) ; return platformApi . prepare ( project , _ . clone ( options ) ) . then ( function ( ) { if ( platform === 'windows' && ! ( platformApi instanceof PlatformApiPoly ) ) { // Windows Api doesn't fire 'pre_package' hook, so we fire it here return new HooksRunner ( projectRoot ) . fire ( 'pre_package' , { wwwPath : platformApi . getPlatformInfo ( ) . locations . www , platforms : [ 'windows' ] , nohooks : options . nohooks } ) ; } } ) . then ( function ( ) { if ( options . browserify ) { var browserify = require ( '../plugman/browserify' ) ; return browserify ( project , platformApi ) ; } } ) . then ( function ( ) { // Handle edit-config in config.xml var platformRoot = path . join ( projectRoot , 'platforms' , platform ) ; var platformJson = PlatformJson . load ( platformRoot , platform ) ; var munger = new PlatformMunger ( platform , platformRoot , platformJson ) ; munger . add_config_changes ( project . projectConfig , /*should_increment=*/ true ) . save_all ( ) ; } ) ; } ) ; } ) ) ; }
Calls `platformApi.prepare` for each platform in project

@param   {string[]}  platformList  List of platforms, added to current project
@param   {string}    projectRoot   Project root directory

@return  {Promise}
Calls platformApi . prepare for each platform in project