remove out file if packing panics

This commit is contained in:
Mark Bates 2019-11-11 16:46:12 -05:00
parent 7ee0500044
commit 8879dba851
1 changed files with 5 additions and 0 deletions

View File

@ -125,6 +125,11 @@ func (e *packCmd) Flags() *flag.FlagSet {
func Package(out string, decls parser.Decls) error { func Package(out string, decls parser.Decls) error {
os.RemoveAll(out) os.RemoveAll(out)
defer func() {
if err := recover(); err != nil {
os.RemoveAll(out)
}
}()
f, err := os.Create(out) f, err := os.Create(out)
if err != nil { if err != nil {