[v2] Always generate into subdir

This commit is contained in:
Lea Anthony
2021-09-21 20:11:25 +10:00
parent 9f235bf78d
commit 981ce4f8ad

View File

@@ -169,23 +169,10 @@ func Install(options *Options) (bool, *Template, error) {
// Did the user want to install in current directory?
if options.TargetDir == "" {
// If the current directory is empty, use it
isEmpty, err := fs.DirIsEmpty(cwd)
if err != nil {
return false, nil, err
options.TargetDir = filepath.Join(cwd, options.ProjectName)
if fs.DirExists(options.TargetDir) {
return false, nil, fmt.Errorf("cannot create project directory. Dir exists: %s", options.TargetDir)
}
if isEmpty {
// Yes - use cwd
options.TargetDir = cwd
} else {
options.TargetDir = filepath.Join(cwd, options.ProjectName)
if fs.DirExists(options.TargetDir) {
return false, nil, fmt.Errorf("cannot create project directory. Dir exists: %s", options.TargetDir)
}
}
} else {
// Get the absolute path of the given directory
targetDir, err := filepath.Abs(filepath.Join(cwd, options.TargetDir))