Update cordova plugins in one command

前端 未结 14 763
故里飘歌
故里飘歌 2020-12-04 06:34

I am wondering is there an easier way to update cordova plugin?

I googled, found a hook (@ year 2013), but this is not 100% what I want.

I know I can do this

14条回答
  •  爱一瞬间的悲伤
    2020-12-04 07:15

    This is my Windows Batch version for update all plugins in one command

    How to use:

    From command line, in the same folder of project, run

    c:\> batchNameFile
    

    or

    c:\> batchNameFile autoupdate
    

    Where "batchNameFile" is the name of .BAT file, with the script below.

    For only test ( first exmple ) or to force every update avaiable ( 2nd example )

    @echo off
    
    cls
    
    set pluginListFile=update.plugin.list
    
    if exist %pluginListFile% del %pluginListFile%
    
    Echo "Reading installed Plugins"
    Call cordova plugins > %pluginListFile%
    echo.
    
    for /F "tokens=1,2 delims= " %%a in ( %pluginListFile% ) do (
       Echo "Checking online version for %%a"
    
       for /F "delims=" %%I in ( 'npm info %%a version' ) do (
         Echo "Local : %%b"
         Echo "Online: %%I"
         if %%b LSS %%I Call :toUpdate %%a %~1
         :cont
         echo.
       )
    )
    
    if exist %pluginListFile% del %pluginListFile%
    
    Exit /B
    
    :toUpdate
    Echo "Need Update !"
    if '%~2' == 'autoupdate' Call :DoUpdate %~1
    goto cont
    
    :DoUpdate
    Echo "Removing Plugin"
    Call cordova plugin rm %~1
    Echo "Adding Plugin"
    Call cordova plugin add %~1
    goto cont
    

    This batch was only tested in Windows 10

提交回复
热议问题