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