Skip to content

Commit 8baa79e

Browse files
committed
[ci] Added more filetypes in generate_metafiles
1 parent 393a949 commit 8baa79e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

scripts/generate_metafiles.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,28 @@ function isfolderempty {
118118

119119
# files or non-empty folders without .meta files
120120
function findorphanfiles {
121-
find ${1-.} -not -name '*.meta' -and -not -path '*/\.*' -and -not -path '.' |
121+
local folder="${1-.}"
122+
find "$folder" -not -name '*.meta' -and -not -path '*/\.*' -and -not -path '.' |
122123
while read path
123124
do
125+
# skip topmost
126+
if [[ "$folder" == "$path" ]]
127+
then
128+
continue
129+
fi
124130
# missing .meta file?
125131
if [ ! -f "${path}.meta" ]
126132
then
127133
# is file?
128-
if [ -f $path ]
134+
if [ -f "$path" ]
129135
then
130136
echo $path
131137
# is folder and not empty?
132-
elif [ -d $path ]
138+
elif [ -d "$path" ]
133139
then
134-
if ! isfolderempty $path
140+
if ! isfolderempty "$path"
135141
then
136-
echo $path
142+
echo "$path"
137143
fi
138144
fi
139145
fi
@@ -148,14 +154,14 @@ function findorphanmeta {
148154
local other="${path/%.meta}"
149155

150156
# is empty folder?
151-
if [ -d $other ]
157+
if [ -d "$other" ]
152158
then
153159
if isfolderempty $other
154160
then
155161
echo $path
156162
fi
157163
# missing file?
158-
elif [ ! -f $other ]
164+
elif [ ! -f "$other" ]
159165
then
160166
echo $path
161167
fi
@@ -164,9 +170,10 @@ function findorphanmeta {
164170

165171
function generatemeta {
166172
local COUNTER=$((0))
173+
local folder="${1-.}"
167174
while read path
168175
do
169-
if [ -d $path ]
176+
if [ -d "$path" ]
170177
then
171178
# folder
172179
metatemplate "" > "${path}.meta"
@@ -178,7 +185,7 @@ function generatemeta {
178185
((COUNTER++))
179186
echo "Generated for \"${path##*.}\" file: ${path}.meta"
180187
fi
181-
done < <(findorphanfiles ${1-.})
188+
done < <(findorphanfiles "$folder")
182189
echo "<<< Generated $COUNTER meta files."
183190
}
184191

@@ -187,14 +194,14 @@ function removeorphans {
187194
while read path
188195
do
189196
local other="${path/%.meta}"
190-
if [ -d $other ]
197+
if [ -d "$other" ]
191198
then
192199
# remove empty folder
193-
rm -rf $other
200+
rm -rf "$other"
194201
fi
195202

196203
# remove meta file
197-
rm $path
204+
rm "$path"
198205
((COUNTER++))
199206
echo "Removed orphaned \".meta\" file: $path"
200207
done < <(findorphanmeta ${1-.})

0 commit comments

Comments
 (0)