#Selectively choosing directories

1 messages · Page 1 of 1 (latest)

high jasper
#

hey! looking for ways to improve this little function:

func (m *Project) LintShell(ctx context.Context, source *dagger.Directory) (string, error) {
    return dag.Container().
        From("shellcheck-alpine").
        WithDirectory("/scripts", source, dagger.ContainerWithDirectoryOpts{Include: []string{"*.sh"}}).
        WithWorkdir("/scripts").
        WithExec([]string{"sh", "-c", "find . -name '*.sh' | xargs shellcheck"}).
        Stdout(ctx)
}

here, id like source to be the root of my monorepo, but then be able in some way to select some subdirectories, rather than try to copy the whole monorepo and filter by *.sh.
is there a way to use the passed in source to template a string and select subdirs? for example,
$source/scripts, $source/ci, etc.

#

i could certainly just add a WithDir for each directory in the function , just curious what the best path is here

#

though, i'd need an array argument i guess. --paths=/scripts,/ci

high jasper