@@ -76,7 +76,7 @@ function findPlugins (deps) {
76
76
)
77
77
}
78
78
79
- function list ( file , context ) {
79
+ function list ( file , context , resetApi = true ) {
80
80
const pkg = folders . readPackage ( file , context )
81
81
plugins = [ ]
82
82
plugins = plugins . concat ( findPlugins ( pkg . devDependencies || { } ) )
@@ -90,7 +90,7 @@ function list (file, context) {
90
90
plugins . unshift ( service )
91
91
}
92
92
93
- resetPluginApi ( context )
93
+ if ( resetApi ) resetPluginApi ( context )
94
94
return plugins
95
95
}
96
96
@@ -379,7 +379,7 @@ async function initPrompts (id, context) {
379
379
await prompts . start ( )
380
380
}
381
381
382
- function update ( id , context , multi = false ) {
382
+ function update ( id , context ) {
383
383
return progress . wrap ( 'plugin-update' , context , async setProgress => {
384
384
setProgress ( {
385
385
status : 'plugin-update' ,
@@ -396,38 +396,56 @@ function update (id, context, multi = false) {
396
396
type : 'info'
397
397
} , context )
398
398
399
- if ( ! multi ) {
400
- notify ( {
401
- title : `Plugin updated` ,
402
- message : `Plugin ${ id } was successfully updated` ,
403
- icon : 'done'
404
- } )
405
- resetPluginApi ( context )
406
- }
399
+ notify ( {
400
+ title : `Plugin updated` ,
401
+ message : `Plugin ${ id } was successfully updated` ,
402
+ icon : 'done'
403
+ } )
404
+ resetPluginApi ( context )
407
405
408
406
currentPluginId = null
409
407
return findOne ( id )
410
408
} )
411
409
}
412
410
413
411
async function updateAll ( context ) {
414
- const plugins = await list ( cwd . get ( ) , context )
415
- let updatedPlugins = [ ]
416
- for ( const plugin of plugins ) {
417
- const version = await getVersion ( plugin , context )
418
- if ( version . current !== version . wanted ) {
419
- updatedPlugins . push ( await update ( plugin . id , context , true ) )
412
+ return progress . wrap ( 'plugins-update' , context , async setProgress => {
413
+ const plugins = await list ( cwd . get ( ) , context , false )
414
+ let updatedPlugins = [ ]
415
+ for ( const plugin of plugins ) {
416
+ const version = await getVersion ( plugin , context )
417
+ if ( version . current !== version . wanted ) {
418
+ updatedPlugins . push ( plugin )
419
+ }
420
420
}
421
- }
422
421
423
- notify ( {
424
- title : `Plugins updated` ,
425
- message : `${ updatedPlugins . length } plugin(s) were successfully updated` ,
426
- icon : 'done'
427
- } )
428
- resetPluginApi ( context )
422
+ if ( ! updatedPlugins . length ) {
423
+ notify ( {
424
+ title : `No updates available` ,
425
+ message : `No plugin to update in the version ranges declared in package.json` ,
426
+ icon : 'done'
427
+ } )
428
+ return [ ]
429
+ }
430
+
431
+ setProgress ( {
432
+ status : 'plugins-update' ,
433
+ args : [ updatedPlugins . length ]
434
+ } )
435
+
436
+ await updatePackage ( cwd . get ( ) , getCommand ( ) , null , updatedPlugins . map (
437
+ p => p . id
438
+ ) . join ( ' ' ) )
429
439
430
- return updatedPlugins
440
+ notify ( {
441
+ title : `Plugins updated` ,
442
+ message : `${ updatedPlugins . length } plugin(s) were successfully updated` ,
443
+ icon : 'done'
444
+ } )
445
+ resetPluginApi ( context )
446
+
447
+ return updatedPlugins
448
+ } )
431
449
}
432
450
433
451
function getApi ( ) {
0 commit comments