diff options
Diffstat (limited to 'common.go')
-rw-r--r-- | common.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -67,7 +67,8 @@ func merge(files map[string][]byte) (merged []byte) { | |||
67 | 67 | ||
68 | // COMPILED and INTERACTIVE modes | 68 | // COMPILED and INTERACTIVE modes |
69 | 69 | ||
70 | func parse(dirPath string, elements map[string][]byte, exts []string, overwrite bool) map[string][]byte { | 70 | func parse(dirPath string, elements map[string][]byte, exts []string, overwrite bool) (map[string][]byte, bool) { |
71 | parsed := false | ||
71 | _, filesList := fcmd.Ls(dirPath) | 72 | _, filesList := fcmd.Ls(dirPath) |
72 | for _, fileName := range filesList { | 73 | for _, fileName := range filesList { |
73 | if isParsable(fileName, exts) && (overwrite || elements[fileName[:len(fileName)-len(path.Ext(fileName))]] == nil) { | 74 | if isParsable(fileName, exts) && (overwrite || elements[fileName[:len(fileName)-len(path.Ext(fileName))]] == nil) { |
@@ -76,9 +77,10 @@ func parse(dirPath string, elements map[string][]byte, exts []string, overwrite | |||
76 | if err != nil { | 77 | if err != nil { |
77 | fmt.Println(err) | 78 | fmt.Println(err) |
78 | } | 79 | } |
80 | parsed = true | ||
79 | } | 81 | } |
80 | } | 82 | } |
81 | return elements | 83 | return elements, parsed |
82 | } | 84 | } |
83 | 85 | ||
84 | func compile(dirPath string, elements map[string][]byte, sourceDir, outputDir, saveAs string, exts []string, recursive bool) { | 86 | func compile(dirPath string, elements map[string][]byte, sourceDir, outputDir, saveAs string, exts []string, recursive bool) { |
@@ -88,7 +90,8 @@ func compile(dirPath string, elements map[string][]byte, sourceDir, outputDir, s | |||
88 | return | 90 | return |
89 | } | 91 | } |
90 | 92 | ||
91 | elements = parse(dirPath, elements, exts, true) | 93 | parsed := false |
94 | elements, parsed = parse(dirPath, elements, exts, true) | ||
92 | 95 | ||
93 | if recursive { | 96 | if recursive { |
94 | dirs, _ := fcmd.Ls(dirPath) | 97 | dirs, _ := fcmd.Ls(dirPath) |
@@ -98,6 +101,10 @@ func compile(dirPath string, elements map[string][]byte, sourceDir, outputDir, s | |||
98 | } | 101 | } |
99 | } | 102 | } |
100 | 103 | ||
104 | if !parsed { | ||
105 | return | ||
106 | } | ||
107 | |||
101 | pagePath := strings.TrimPrefix(dirPath, sourceDir) | 108 | pagePath := strings.TrimPrefix(dirPath, sourceDir) |
102 | 109 | ||
103 | template := merge(elements) | 110 | template := merge(elements) |