@@ -66,41 +66,36 @@ func add() *cobra.Command {
66
66
isDir = stat .IsDir ()
67
67
}
68
68
69
- var summary []string
70
69
var failed []string
71
70
if isDir {
72
71
files , err := os .ReadDir (args [0 ])
73
72
if err != nil {
74
73
return err
75
74
}
76
75
for _ , file := range files {
77
- vsixPath := filepath .Join (args [0 ], file .Name ())
78
- _ , _ = fmt .Fprintf (cmd .OutOrStdout (), "Adding %s...\r \n " , vsixPath )
79
- s , err := doAdd (ctx , vsixPath , store )
76
+ s , err := doAdd (ctx , filepath .Join (args [0 ], file .Name ()), store )
80
77
if err != nil {
78
+ _ , _ = fmt .Fprintf (cmd .OutOrStdout (), "Failed to unpack %s: %s\n " , file .Name (), err .Error ())
81
79
failed = append (failed , file .Name ())
82
- summary = append (summary , fmt .Sprintf ("Failed to unpack %s: %s" , file .Name (), err .Error ()))
83
80
} else {
84
- summary = append ( summary , s ... )
81
+ _ , _ = fmt . Fprintln ( cmd . OutOrStdout (), strings . Join ( s , " \n " ) )
85
82
}
86
83
}
87
84
} else {
88
- _ , _ = fmt .Fprintf (cmd .OutOrStdout (), "Adding %s...\r \n " , args [0 ])
89
- summary , err = doAdd (ctx , args [0 ], store )
85
+ s , err := doAdd (ctx , args [0 ], store )
90
86
if err != nil {
91
87
return err
92
88
}
89
+ _ , _ = fmt .Fprintln (cmd .OutOrStdout (), strings .Join (s , "\n " ))
93
90
}
94
91
95
- _ , err = fmt .Fprintln (cmd .OutOrStdout (), strings .Join (summary , "\n " ))
96
- failedCount := len (failed )
97
- if failedCount > 0 {
92
+ if len (failed ) > 0 {
98
93
return xerrors .Errorf (
99
94
"Failed to add %s: %s" ,
100
- util .Plural (failedCount , "extension" , "" ),
95
+ util .Plural (len ( failed ) , "extension" , "" ),
101
96
strings .Join (failed , ", " ))
102
97
}
103
- return err
98
+ return nil
104
99
},
105
100
}
106
101
0 commit comments