Skip to content
Snippets Groups Projects
Verified Commit 3560b1f7 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: exclude works with bash completion

parent 55cb1ee5
No related branches found
Tags 0.5.4
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="color-scheme" content="dark light">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page 1</title>
<style>
*:not(:defined) {
visibility: hidden;
}
</style>
</head>
<body>
<h1>Page 1</h1>
<footer>
<p>Footer</p>
</footer>
</body>
\ No newline at end of file
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8"/>
<meta name="color-scheme" content="dark light"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Page 2</title>
<style>
*:not(:defined) {
visibility: hidden;
}
</style>
</head>
<body>
<h1>Page 2</h1>
<footer>
<p>Footer</p>
</footer>
</body></html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="color-scheme" content="dark light">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exclude this</title>
<style>
*:not(:defined) {
visibility: hidden;
}
</style>
</head>
<body>
<h1>Exclude This</h1>
</body>
\ No newline at end of file
sync:
- source:
path: "source/page1.html"
selector: "footer"
destination:
path: "source/"
exclude:
- "source/page1.html"
- "source/parts/*"
......@@ -91,31 +91,28 @@ func SyncHtml(p string) error {
return nil
}
if exclude != nil {
for _, e := range exclude {
e, err := filepath.Abs(e)
if err != nil {
return err
}
if e == pp {
return nil
}
}
}
ext := filepath.Ext(pp)
if ext == ".html" {
if ext != ".html" {
return nil
}
var dd *html.Node
if dd, err = readHTML(pp); err != nil {
return err
}
excludeFlag, err2 := checkExcludes(exclude, pp)
if err2 != nil {
return err2
}
destinationFiles[pp] = dd
destinationFile[absSource] = append(destinationFile[absSource], pp)
if excludeFlag {
return nil
}
var dd *html.Node
if dd, err = readHTML(pp); err != nil {
return err
}
destinationFiles[pp] = dd
destinationFile[absSource] = append(destinationFile[absSource], pp)
return nil
}); err != nil {
return err
......@@ -123,22 +120,13 @@ func SyncHtml(p string) error {
} else if filepath.Ext(d) == ".html" {
if exclude != nil {
for _, e := range exclude {
e, err := filepath.Abs(e)
if err != nil {
return err
}
if e == d {
return nil
}
if r, err := filepath.Match(e, d); err != nil {
return err
} else if r {
return nil
}
excludeFlag, err2 := checkExcludes(exclude, d)
if err2 != nil {
return err2
}
if excludeFlag {
continue
}
}
......@@ -259,3 +247,25 @@ func SyncHtml(p string) error {
return nil
}
func checkExcludes(exclude []string, d string) (bool, error) {
for _, e := range exclude {
e, err := filepath.Abs(e)
if err != nil {
return false, err
}
if e == d {
return true, nil
}
if r, err := filepath.Match(e, d); err != nil {
return false, err
} else if r {
return true, nil
}
}
return false, nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment