Skip to content

Commit

Permalink
Changed variable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverLok committed Dec 2, 2024
1 parent b2ba03a commit fdb1fc7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/common/filespec.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (this *FileSpec) CopyTarget(baseDir string, destDir string, onlyContents bo
// no-op.
return nil
case FILESPEC_TYPE_PATH:
return this.matchAndCopyTargets(baseDir, destDir, onlyContents)
return this.matchAndCopyPaths(baseDir, destDir, onlyContents)
case FILESPEC_TYPE_GIT:
return this.copyGit(destDir)
case FILESPEC_TYPE_URL:
Expand All @@ -235,7 +235,7 @@ func (this *FileSpec) CopyTarget(baseDir string, destDir string, onlyContents bo
}
}

func (this *FileSpec) matchAndCopyTargets(baseDir string, destDir string, onlyContents bool) error {
func (this *FileSpec) matchAndCopyPaths(baseDir string, destDir string, onlyContents bool) error {
if !this.IsPath() {
return fmt.Errorf("Cannot match targets: FileSpec must be a path.")
}
Expand All @@ -261,28 +261,28 @@ func (this *FileSpec) matchAndCopyTargets(baseDir string, destDir string, onlyCo
destPath = filepath.Join(destDir, filename)
}

targets, err := filepath.Glob(fileSpecPath)
paths, err := filepath.Glob(fileSpecPath)
if err != nil {
return fmt.Errorf("Failed to resolve the path pattern '%s': '%w'.", this.Path, err)
}

if len(targets) == 0 {
if len(paths) == 0 {
return fmt.Errorf("No targets found for the path '%s'.", this.Path)
}

// Create a new directory if multiple targets are matched.
if !util.PathExists(destPath) && len(targets) > 1 {
// Create a new directory if multiple paths are matched.
if !util.PathExists(destPath) && len(paths) > 1 {
err := util.MkDir(destPath)
if err != nil {
return fmt.Errorf("Failed to make a directory for the Filespec at path '%s': '%v'.", destPath, err)
}
}

// Loop over each matched path and copy it to the destination.
for _, target := range targets {
err := copyPath(target, destPath, onlyContents)
for _, path := range paths {
err := copyPath(path, destPath, onlyContents)
if err != nil {
return fmt.Errorf("Failed to copy target '%s': '%w'.", target, err)
return fmt.Errorf("Failed to copy target '%s': '%w'.", path, err)
}
}

Expand Down

0 comments on commit fdb1fc7

Please sign in to comment.