File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ if(myArgs[0] == "enable" && myArgs[1]){
38
38
else if ( myArgs [ 0 ] == "upgrade" && myArgs [ 1 ] ) {
39
39
if ( plugins . indexOf ( myArgs [ 1 ] ) > - 1 ) {
40
40
require ( '../../../api/utils/log' ) . setLevel ( 'db:write' , 'mute' ) ;
41
- manager . installPlugin ( myArgs [ 1 ] ) ;
41
+ manager . upgradePlugin ( myArgs [ 1 ] ) ;
42
42
}
43
43
else {
44
44
console . log ( "Plugin is not installed" ) ;
Original file line number Diff line number Diff line change @@ -488,6 +488,33 @@ var pluginManager = function pluginManager(){
488
488
} ) ;
489
489
}
490
490
491
+ this . upgradePlugin = function ( plugin , callback ) {
492
+ console . log ( 'Upgrading plugin %j...' , plugin ) ;
493
+ callback = callback || function ( ) { } ;
494
+ try {
495
+ var errors ;
496
+ var scriptPath = path . join ( __dirname , plugin , 'install.js' ) ;
497
+ delete require . cache [ require . resolve ( scriptPath ) ] ;
498
+ require ( scriptPath ) ;
499
+ }
500
+ catch ( ex ) {
501
+ console . log ( ex . stack ) ;
502
+ errors = true ;
503
+ return callback ( errors ) ;
504
+ }
505
+ var eplugin = global . enclose ? global . enclose . plugins [ plugin ] : null ;
506
+ if ( eplugin && eplugin . prepackaged ) return callback ( errors ) ;
507
+ var cwd = eplugin ? eplugin . rfs : path . join ( __dirname , plugin ) ;
508
+ var child = exec ( 'npm update --unsafe-perm' , { cwd : cwd } , function ( error ) {
509
+ if ( error ) {
510
+ errors = true ;
511
+ console . log ( 'error: %j' , error ) ;
512
+ }
513
+ console . log ( 'Done upgrading plugin %j' , plugin ) ;
514
+ callback ( errors ) ;
515
+ } ) ;
516
+ }
517
+
491
518
this . uninstallPlugin = function ( plugin , callback ) {
492
519
console . log ( 'Uninstalling plugin %j...' , plugin ) ;
493
520
callback = callback || function ( ) { } ;
You can’t perform that action at this time.
0 commit comments