|
|
@ -104,6 +104,8 @@ with relevant html classes and tags for easy styling. |
|
|
|
Example: |
|
|
|
|
|
|
|
distribusi -p <path> -s |
|
|
|
|
|
|
|
See https://pkg.go.dev/path/filepath#Match for supported patterns for "-i/--ignore".
|
|
|
|
`, |
|
|
|
Flags: []cli.Flag{ |
|
|
|
&cli.StringFlag{ |
|
|
@ -127,7 +129,7 @@ Example: |
|
|
|
&cli.StringFlag{ |
|
|
|
Name: "ignore", |
|
|
|
Aliases: []string{"i"}, |
|
|
|
Usage: "ignore specific paths (e.g. \"mydir, myfile.txt\" )", |
|
|
|
Usage: "ignore specific paths, (e.g. \"*.gif, *.txt, mydir\" )", |
|
|
|
Value: "", |
|
|
|
}, |
|
|
|
&cli.StringFlag{ |
|
|
@ -228,7 +230,11 @@ func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
|
|
|
|
if err := filepath.Walk(root, func(fpath string, finfo os.FileInfo, err error) error { |
|
|
|
|
|
|
|
if skip := shouldSkip(c, fpath, ignore); skip { |
|
|
|
skip, err := shouldSkip(c, fpath, ignore) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if skip { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
@ -283,7 +289,11 @@ func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
for _, dir := range dirs { |
|
|
|
fname := filepath.Base(dir) |
|
|
|
|
|
|
|
if skip := shouldSkip(c, dir, ignore); skip { |
|
|
|
skip, err := shouldSkip(c, fname, ignore) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if skip { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
@ -301,7 +311,11 @@ func distribusify(c *cli.Context, root string, ignore []string) error { |
|
|
|
for _, file := range files { |
|
|
|
fname := filepath.Base(file) |
|
|
|
|
|
|
|
if skip := shouldSkip(c, file, ignore); skip { |
|
|
|
skip, err := shouldSkip(c, fname, ignore) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if skip { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
@ -629,19 +643,27 @@ func wipeGeneratedFiles(dir string) error { |
|
|
|
} |
|
|
|
|
|
|
|
// shouldSkip checks if paths should be skipped over.
|
|
|
|
func shouldSkip(c *cli.Context, fpath string, ignore []string) bool { |
|
|
|
if sliceContains(ignore, filepath.Base(fpath)) { |
|
|
|
return true |
|
|
|
func shouldSkip(c *cli.Context, fpath string, ignore []string) (bool, error) { |
|
|
|
for _, pattern := range ignore { |
|
|
|
match, err := filepath.Match(pattern, filepath.Base(fpath)) |
|
|
|
if err != nil { |
|
|
|
return false, err |
|
|
|
} |
|
|
|
if match { |
|
|
|
logrus.Debugf("skipping %s, matched %s", filepath.Base(fpath), pattern) |
|
|
|
return true, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fpaths := strings.Split(fpath, "/") |
|
|
|
for _, part := range fpaths { |
|
|
|
if strings.HasPrefix(part, ".") { |
|
|
|
if !c.Bool("hidden") { |
|
|
|
return true |
|
|
|
logrus.Debugf("skipping %s, hidden directory", fpath) |
|
|
|
return true, nil |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
return false, nil |
|
|
|
} |
|
|
|