@@ -133,24 +133,36 @@ func validateCurrentDirectoryForInit() error {
133133}
134134
135135// resolveTargetDirectory determines the target directory for the Flow project
136- // based on user input. Empty input means current directory.
136+ // based on user input by resolving a candidate path and checking if it equals
137+ // the current working directory.
137138func resolveTargetDirectory (userInput string ) (string , error ) {
138- if strings .TrimSpace (userInput ) == "" {
139- // Validate current directory for Flow project conflicts
139+ pwd , err := os .Getwd ()
140+ if err != nil {
141+ return "" , fmt .Errorf ("failed to get current working directory: %w" , err )
142+ }
143+
144+ trimmed := strings .TrimSpace (userInput )
145+
146+ // Build a candidate absolute path for comparison
147+ var candidate string
148+ if trimmed == "" {
149+ candidate = pwd
150+ } else if filepath .IsAbs (trimmed ) {
151+ candidate = filepath .Clean (trimmed )
152+ } else {
153+ candidate = filepath .Clean (filepath .Join (pwd , trimmed ))
154+ }
155+
156+ // If candidate resolves to current directory, validate and use it
157+ if candidate == filepath .Clean (pwd ) {
140158 if err := validateCurrentDirectoryForInit (); err != nil {
141159 return "" , err
142160 }
143-
144- // Use current directory
145- pwd , err := os .Getwd ()
146- if err != nil {
147- return "" , fmt .Errorf ("failed to get current working directory: %w" , err )
148- }
149161 return pwd , nil
150162 }
151163
152- // Use provided name to create new directory
153- return getTargetDirectory (userInput )
164+ // Otherwise, use provided name/path to create or validate new directory
165+ return getTargetDirectory (trimmed )
154166}
155167
156168func updateGitignore (targetDir string , readerWriter flowkit.ReaderWriter ) error {
0 commit comments