function setPackagesState(app, dependencies, cb) {
  var zealPacks = {};
  let promises = [];

  _.forEach(dependencies, function(val, key) {
    buildPackagesList(app, zealPacks, val, key, promises);
  });
  /* app.debug('Installed themes: %O', app.locals.themes);
  app.debug('Installed apps: %O', app.locals.apps); */
  Promise.all(promises).then(() => {
    app.emit('zealder packages loaded');

    // if callback passed
    if (cb) cb(zealPacks);
  });
}
function setPackagesState(app, dependencies, cb) {
  var zealPacks = {};
  let promises = [];

  _.forEach(dependencies, function(val, key) {
    buildPackagesList(app, zealPacks, val, key, promises);
  });
  
  Promise.all(promises).then(() => {
    app.emit('zealder packages loaded');

    
    if (cb) cb(zealPacks);
  });
}
function setPackagesState ( app , dependencies , cb ) { var zealPacks = { } ; let promises = [ ] ; _ . forEach ( dependencies , function ( val , key ) { buildPackagesList ( app , zealPacks , val , key , promises ) ; } ) ; /* app.debug('Installed themes: %O', app.locals.themes);
  app.debug('Installed apps: %O', app.locals.apps); */ Promise . all ( promises ) . then ( ( ) => { app . emit ( 'zealder packages loaded' ) ; // if callback passed if ( cb ) cb ( zealPacks ) ; } ) ; }
for saving packages info to state
for saving packages info to state