Skip to content

Commit

Permalink
Use async.parallel to run #provisioning() and #entitlements() in para…
Browse files Browse the repository at this point in the history
…llel - also avoids nested callbacks, closes #5
  • Loading branch information
matiassingers committed Jan 26, 2015
1 parent 48510ad commit 37de9e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
22 changes: 8 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

var async = require('async');
var plist = require('simple-plist');
var decompress = require('decompress-zip');
var provisioning = require('provisioning');
Expand All @@ -25,27 +26,20 @@ module.exports = function (file, callback){

data.metadata = plist.readFileSync(path + 'Info.plist');

if(!fs.existsSync(path + 'embedded.mobileprovision')){
return cleanUp();
}

provisioning(path + 'embedded.mobileprovision', function(error, provision){
async.parallel([
async.apply(provisioning, path + 'embedded.mobileprovision'),
async.apply(entitlements, path)
], function(error, results){
if(error){
return cleanUp(error);
}

data.provisioning = provision;
data.provisioning = results[0];
delete data.provisioning.DeveloperCertificates;

if(!which.sync('codesign')){
return cleanUp();
}
data.entitlements = results[1];

entitlements(path, function(error, entitlement) {
data.entitlements = entitlement;

return cleanUp();
});
return cleanUp();
});
});

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"homepage": "https://github.com/matiassingers/ipa-metadata",
"dependencies": {
"async": "0.9.0",
"chalk": "0.5.1",
"cli-table": "0.3.1",
"decompress-zip": "0.0.8",
Expand Down

0 comments on commit 37de9e3

Please sign in to comment.