@@ -76,7 +76,7 @@ function findPlugins (deps) {
7676 )
7777}
7878
79- function list ( file , context ) {
79+ function list ( file , context , resetApi = true ) {
8080 const pkg = folders . readPackage ( file , context )
8181 plugins = [ ]
8282 plugins = plugins . concat ( findPlugins ( pkg . devDependencies || { } ) )
@@ -90,7 +90,7 @@ function list (file, context) {
9090 plugins . unshift ( service )
9191 }
9292
93- resetPluginApi ( context )
93+ if ( resetApi ) resetPluginApi ( context )
9494 return plugins
9595}
9696
@@ -379,7 +379,7 @@ async function initPrompts (id, context) {
379379 await prompts . start ( )
380380}
381381
382- function update ( id , context , multi = false ) {
382+ function update ( id , context ) {
383383 return progress . wrap ( 'plugin-update' , context , async setProgress => {
384384 setProgress ( {
385385 status : 'plugin-update' ,
@@ -396,38 +396,56 @@ function update (id, context, multi = false) {
396396 type : 'info'
397397 } , context )
398398
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 )
407405
408406 currentPluginId = null
409407 return findOne ( id )
410408 } )
411409}
412410
413411async 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+ }
420420 }
421- }
422421
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 ( ' ' ) )
429439
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+ } )
431449}
432450
433451function getApi ( ) {
0 commit comments