@@ -81,6 +81,7 @@ func root(args []string) error {
8181 flagsParse (fs , args [1 :])
8282
8383 s .CheckUpdates (ctx )
84+
8485 case "update" :
8586 if len (args ) < 2 {
8687 return fmt .Errorf ("language argument is missing" )
@@ -91,11 +92,15 @@ func root(args []string) error {
9192 flagsParse (fs , args [2 :])
9293
9394 s .Update (ctx , args [1 ], * force )
95+ s .writeGrammarsFile (ctx )
96+
9497 case "update-all" :
9598 fs := flag .NewFlagSet ("update-all" , flag .ExitOnError )
9699 flagsParse (fs , args [1 :])
97100
98- s .UpdateAll (ctx )
101+ s .UpdateAll (ctx , true )
102+ s .writeGrammarsFile (ctx )
103+
99104 default :
100105 return fmt .Errorf ("unknown sub-command" )
101106 }
@@ -194,33 +199,20 @@ func (s *UpdateService) Update(ctx context.Context, language string, force bool)
194199 }
195200
196201 s .downloadGrammar (ctx , grammar )
197- s .writeGrammarsFile (ctx )
198202}
199203
200- func (s * UpdateService ) UpdateAll (ctx context.Context ) {
201- newVersions := s .fetchNewVersions ()
202-
204+ func (s * UpdateService ) UpdateAll (ctx context.Context , force bool ) {
203205 wg := sync.WaitGroup {}
204- for i , g := range s .grammars {
205- v := newVersions [i ]
206- if v == nil {
207- continue
208- }
209-
206+ for _ , g := range s .grammars {
210207 wg .Add (1 )
211- g .Reference = v .Reference
212- g .Revision = v .Revision
213208
214209 go func (g * Grammar ) {
215210 defer wg .Done ()
216211
217- s .downloadGrammar (ctx , g )
212+ s .Update (ctx , g . Language , force )
218213 }(g )
219214 }
220-
221215 wg .Wait ()
222-
223- s .writeGrammarsFile (ctx )
224216}
225217
226218func (s * UpdateService ) downloadGrammar (ctx context.Context , g * Grammar ) {
@@ -310,7 +302,7 @@ func (s *UpdateService) fetchFile(ctx context.Context, url string) []byte {
310302 defer resp .Body .Close ()
311303
312304 if resp .StatusCode != 200 {
313- logAndExit ( logger , "incorrect response status code" , "statusCode" , resp .StatusCode )
305+ logger . Error ( "incorrect response status code" , "statusCode" , resp .StatusCode )
314306 }
315307
316308 b , err := io .ReadAll (resp .Body )
0 commit comments