always return a cleanup function from scope (#183)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2020-09-25 16:20:06 -04:00 committed by GitHub
parent 576fbc898b
commit 03378e976c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,11 +54,11 @@ func NewScope(userInput string, o Option) (Scope, func(), error) {
case directoryScheme:
fileMeta, err := fs.Stat(location)
if err != nil {
return Scope{}, nil, fmt.Errorf("unable to stat dir=%q: %w", location, err)
return Scope{}, func() {}, fmt.Errorf("unable to stat dir=%q: %w", location, err)
}
if !fileMeta.IsDir() {
return Scope{}, nil, fmt.Errorf("given path is not a directory (path=%q): %w", location, err)
return Scope{}, func() {}, fmt.Errorf("given path is not a directory (path=%q): %w", location, err)
}
s, err := NewScopeFromDir(location)