Return errors if told to output to a directory and writing a file fails

This commit is contained in:
2020-03-07 10:54:21 -06:00
parent 2329fd5636
commit 0e4c6557ca

View File

@ -100,10 +100,14 @@ func finalize(config Config, buf map[FileType]*bytes.Buffer) (map[FileType]*Comp
} }
dir := filepath.Join(config.OutputDir, string(key)) dir := filepath.Join(config.OutputDir, string(key))
os.MkdirAll(dir, 0755) if err := os.MkdirAll(dir, 0755); err != nil {
return nil, err
}
destFile := filepath.Join(dir, "app-"+ret[key].Hash+ext) destFile := filepath.Join(dir, "app-"+ret[key].Hash+ext)
ioutil.WriteFile(destFile, bytes, 0644) if err := ioutil.WriteFile(destFile, bytes, 0644); err != nil {
return nil, err
}
ret[key].OutputPath = destFile ret[key].OutputPath = destFile
} }
} }