after_prepare.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. module.exports = function (context) {
  3. var req = context.requireCordovaModule,
  4. Q = req('q'),
  5. path = req('path'),
  6. ET = req('elementtree'),
  7. cordova = req('cordova'),
  8. cordova_lib = cordova.cordova_lib,
  9. cordova_lib_util = req('cordova-lib/src/cordova/util'),
  10. fs = require("./lib/filesystem")(Q, req('fs'), path),
  11. settings = require("./lib/settings")(fs, path),
  12. platforms = {};
  13. platforms.android = require("./lib/android")(context);
  14. platforms.ios = require("./lib/ios")(Q, fs, path, req('plist'), req('xcode'));
  15. // platforms.browser = require("./lib/browser")(Q, fs, path, req('plist'), req('xcode'));
  16. return settings.get()
  17. .then(function (config) {
  18. var promises = [];
  19. context.opts.platforms.forEach (function (platformName) {
  20. if (platforms[platformName] && platforms[platformName].build) {
  21. promises.push (platforms[platformName].build (config));
  22. }
  23. });
  24. return Q.all(promises);
  25. })
  26. .catch(function(err) {
  27. if (err.code === 'NEXIST') {
  28. console.log("app-settings.json not found: skipping build");
  29. return;
  30. }
  31. console.log ('unhandled exception', err);
  32. throw err;
  33. });
  34. };