lib/job-manager.js
/*
 * unpacks a packed app from remote root
 * @param app {Object}: the app descriptor recived from remote root
 */
unpacks a packed app from remote root
@param app {Object}: the app descriptor recived from remote root
unpacks a packed app from remote root @param app { Object } : the app descriptor recived from remote root
function unpack(app) {
     return new Promise(function(resolve, reject) {
         var unpacks_dir = __dirname + '/../.unpacks/';
         fs.stat(unpacks_dir, function(err, stats) {
             if(err) {
                 try {
                    fs.mkdirSync(unpacks_dir);
                 }
                 catch(err) { return reject(err); }
             }
             var data = new Buffer(app.pckg, 'base64');
             zipper.unzip(data, function(err, unzipped) {
                 if(err) {
                     return reject(err);
                 }
                 unzipped.save(unpacks_dir, function(err) {
                     if(err) {
                         return reject(err);
                     }
                     resolve(unpacks_dir + "app_" + app.id + ".js");
                 });
             });
         });
     });
 }
function unpack ( app ) { return new Promise ( function ( resolve , reject ) { var unpacks_dir = __dirname + '/../.unpacks/' ; fs . stat ( unpacks_dir , function ( err , stats ) { if ( err ) { try { fs . mkdirSync ( unpacks_dir ) ; } catch ( err ) { return reject ( err ) ; } } var data = new Buffer ( app . pckg , 'base64' ) ; zipper . unzip ( data , function ( err , unzipped ) { if ( err ) { return reject ( err ) ; } unzipped . save ( unpacks_dir , function ( err ) { if ( err ) { return reject ( err ) ; } resolve ( unpacks_dir + "app_" + app . id + ".js" ) ; } ) ; } ) ; } ) ; } ) ; }
unpacks a packed app from remote root
 @param app {Object}: the app descriptor recived from remote root
unpacks a packed app from remote root @param app { Object } : the app descriptor recived from remote root
// check if the unpaking directory exists