Просмотр исходного кода

Fix CSS comment style in dotsync warning header

Block comment prefixes (/* */) now emit a single valid CSS comment
instead of unclosed /* on each line.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
G. Capella 1 день назад
Родитель
Сommit
31fe891ef5
1 измененных файлов с 17 добавлено и 7 удалено
  1. 17 7
      start

+ 17 - 7
start

@@ -70,8 +70,9 @@ dir_has_markers() {
     grep -rqlE '@(host|group) ' "$1" 2>/dev/null
 }
 
-# Detect the comment prefix from the first marker line in a file
-detect_comment_prefix() {
+# Detect the comment style from the first marker line in a file
+# Returns "block" for /* */ style, or the line-comment prefix (# // ; --)
+detect_comment_style() {
     local src="$1"
     local marker_line
     marker_line=$(grep -m1 -E '@(host|group) ' "$src")
@@ -79,7 +80,12 @@ detect_comment_prefix() {
     local prefix="${marker_line%%@*}"
     # Trim trailing whitespace
     prefix="${prefix%"${prefix##*[![:space:]]}"}"
-    echo "$prefix"
+    # Check if it's a block comment opener
+    if [[ "$prefix" == "/*" ]]; then
+        echo "block"
+    else
+        echo "$prefix"
+    fi
 }
 
 # Process a file with @host/@group markers, outputting only matching sections
@@ -320,12 +326,16 @@ sub_sync(){
                 rm "$dest"
             fi
 
-            local comment_prefix
-            comment_prefix=$(detect_comment_prefix "$src")
+            local comment_style
+            comment_style=$(detect_comment_style "$src")
 
             {
-                echo "$comment_prefix DO NOT EDIT - Generated by dotsync from:"
-                echo "$comment_prefix $src"
+                if [[ "$comment_style" == "block" ]]; then
+                    echo "/* DO NOT EDIT - Generated by dotsync from: $src */"
+                else
+                    echo "$comment_style DO NOT EDIT - Generated by dotsync from:"
+                    echo "$comment_style $src"
+                fi
                 echo ""
                 process_markers "$src"
             } > "$dest.dotsync_tmp"