Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update the message shown when the output directory exists #931

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,31 @@ func checkSourcePath(srcpath string) {
func checkOutputPath(outpath string, overwrite bool) {
fi, err := os.Stat(outpath)
if os.IsNotExist(err) {
logrus.Debugf("Transformed artifacts will be written to %s", outpath)
logrus.Debugf("Transformed artifacts will be written to a directory at path '%s'", outpath)
return
}
if err != nil {
logrus.Fatalf("Error while accessing output directory at path %s Error: %q . Exiting", outpath, err)
logrus.Fatalf("Error while accessing output directory at path '%s' Error: %q . Exiting", outpath, err)
}
if !overwrite {
logrus.Fatalf("Output directory %s exists. Exiting", outpath)
logrus.Fatalf(`The output directory '%s' already exists.
Please either:
- remove the output directory
- specify the '--%s' flag to overwrite the output directory
- use the '--%s' flag to specify a different output directory
Exiting.`, outpath, overwriteFlag, outputFlag)
}
if !fi.IsDir() {
logrus.Fatalf("Output path %s is a file. Expected a directory. Exiting", outpath)
logrus.Fatalf("Output path '%s' is a file. Expected a directory. Exiting", outpath)
}
pwd, err := os.Getwd()
if err != nil {
logrus.Fatalf("Failed to get the current working directory. Error: %q", err)
}
if common.IsParent(pwd, outpath) {
logrus.Fatalf("The given output directory %s is a parent of the current working directory.", outpath)
logrus.Fatalf("The given output directory '%s' is a parent of the current working directory.", outpath)
}
logrus.Infof("Output directory %s exists. The contents might get overwritten.", outpath)
logrus.Infof("Output directory '%s' exists. The contents might get overwritten.", outpath)
}

func startQA(flags qaflags) {
Expand Down