简体   繁体   English

如何更新cordova.js?

[英]How to update cordova.js?

I need to update cordova.js in order to have issue CB-7868 fixed on a Cordova project of mine. 我需要更新cordova.js才能在我的Cordova项目上解决问题CB-7868。

I ran all commands stated in this post but I can't get cordova.js updated. 我运行了这篇文章中陈述的所有命令,但是我无法更新cordova.js。

My Cordova project is for the Android platform. 我的Cordova项目适用于Android平台。

You have to manually update NPM package with fix, or wait for next tools release (later then Nov 13) 您必须使用修复程序手动更新NPM软件包,或者等待下一个工具发布(11月13日之后)

  • If you will wait for next release then you should run cordova platform update android 如果您将等待下一个版本 ,则应运行cordova platform update android

  • If you want to one-time patch then you have to replace content of platforms/android/assets/www/cordova.js with your patched version, or modify that file according to your needs. 如果要进行一次修补,则必须用修补的版本替换platforms/android/assets/www/cordova.js ,或根据需要修改该文件。

  • If you want to permanently have manually patch then you have to do following steps. 如果要永久性手动打补丁,则必须执行以下步骤。

    a) Open cordova NPM package where it is stored by NPM. a)打开由NPM存储的cordova NPM软件包。

    On Windows : %appdata%\\npm-cache\\cordova-js 在Windows上 :%appdata%\\ npm-cache \\ cordova-js

    On Linux ~/.npm/cordova-js Linux〜/ .npm / cordova-js上

    b) Inside that you will see specific version of Cordova, 3.7.1 for example. b)在其中,您将看到Cordova的特定版本,例如3.7.1。

    c) Inside that folder package.tgz, unpack it content to another folder, let's use ~/cordova-js-modified for reference. c)在该文件夹package.tgz中,将其内容解压缩到另一个文件夹,让我们使用~/cordova-js-modified作为参考。

    d) Modify file package/cordova.js according to your needs and save. d)根据需要修改文件package/cordova.js并保存。

    e) Repack content of ~/cordova-js-modified to package.tgz and place it again in the 3.7.1 folder. e)将~/cordova-js-modified内容重新打包为package.tgz然后将其再次放置在3.7.1文件夹中。

    f) Now you will have modified version which will be applied each time you run cordova commands. f)现在您将拥有修改的版本,该版本将在每次运行cordova命令时应用。

I ended up doing as follows 我最终做了如下

  • copy platforms/android/assets/www/cordova.js to www/cordova.patched.js ; platforms/android/assets/www/cordova.jswww/cordova.patched.js
  • edit www/cordova.patched.js to replace clobber function with the updated one from cordova-js@3.7.2 ; 编辑www/cordova.patched.js取代clobber与更新的一个从功能cordova-js@3.7.2 ;
  • edit www/index.html to link cordova.patched.js instead of cordova.js ; 编辑www/index.html以链接cordova.patched.js而不是cordova.js
  • run cordova prepare android . 运行cordova prepare android

I also put a console.warn to remember I'm using a patched version of cordova.js . 我还放置了一个console.warn以记住我正在使用cordova.js的补丁版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM