Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

53 рядки
2.1 KiB

  1. module.exports = function(ctx) {
  2. if (ctx.opts && ctx.opts.platforms && ctx.opts.platforms.indexOf('windows') > -1
  3. && ctx.opts.options) {
  4. var path = require('path');
  5. var shell = ctx.requireCordovaModule('shelljs');
  6. var nopt = ctx.requireCordovaModule('nopt');
  7. // parse and validate args
  8. var args = nopt({
  9. 'archs': [String],
  10. 'appx': String,
  11. 'phone': Boolean,
  12. 'win': Boolean,
  13. 'bundle': Boolean,
  14. 'packageCertificateKeyFile': String,
  15. 'packageThumbprint': String,
  16. 'publisherId': String,
  17. 'buildConfig': String
  18. }, {}, ctx.opts.options.argv, 0);
  19. // Check if --appx flag is passed so that we have a project build version override:
  20. var isWin10 = args.appx && args.appx.toLowerCase() === 'uap';
  21. // Else check "windows-target-version" preference:
  22. if (!isWin10) {
  23. var configXml = shell.ls(path.join(ctx.opts.projectRoot, 'config.xml'))[0];
  24. var reTargetVersion = /<preference\s+name="windows-target-version"\s+value="(.+)"\s*\/>/i;
  25. var targetVersion = shell.grep(reTargetVersion, configXml);
  26. var result = reTargetVersion.exec(targetVersion);
  27. if (result !== null) {
  28. var match = result[1];
  29. isWin10 = parseInt(match.split('.'), 10) > 8;
  30. }
  31. }
  32. // Non-AnyCPU arch is required for Windows 10 (UWP) projects only:
  33. if (isWin10) {
  34. var rawArchs = ctx.opts.options.archs || args.archs;
  35. var archs = rawArchs ? rawArchs.split(' ') : [];
  36. // Avoid "anycpu" arch:
  37. if (archs.length === 0 || archs.some(function (item) {
  38. return item.toLowerCase() === 'anycpu';
  39. })) {
  40. throw new Error('You must specify an architecture to include the proper ZXing library version.'
  41. + '\nUse \'cordova run windows -- --arch="x64"\' or \'cordova run windows -- --arch="arm" --phone --device\' for example.');
  42. }
  43. }
  44. }
  45. }