From 48b4023f416ce4663078f563d39e44d386a53b77 Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Wed, 20 Nov 2024 16:27:36 +0100
Subject: [PATCH] fix: check if data-bob-source is set #9

---
 .idea/runConfigurations/run_example_generate.xml | 5 +++++
 .idea/runConfigurations/run_example_prepare_.xml | 5 +++++
 source/javascript/generate.go                    | 7 ++++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/.idea/runConfigurations/run_example_generate.xml b/.idea/runConfigurations/run_example_generate.xml
index e80d7d3..4c499da 100644
--- a/.idea/runConfigurations/run_example_generate.xml
+++ b/.idea/runConfigurations/run_example_generate.xml
@@ -3,6 +3,11 @@
     <module name="bob" />
     <working_directory value="$PROJECT_DIR$" />
     <parameters value=" html generate --input $PROJECT_DIR$/examples/example2/build/ --output $PROJECT_DIR$/examples/example2/dist --data-files $PROJECT_DIR$/examples/example2/pages/" />
+    <envs>
+      <env name="CGO_ENABLED" value="0 " />
+      <env name="CGO_CFLAGS" value="-O2 -U_FORTIFY_SOURCE" />
+      <env name="CGO_LDFLAGS" value="-U_FORTIFY_SOURCE" />
+    </envs>
     <EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension">
       <option name="DIRENV_ENABLED" value="false" />
       <option name="DIRENV_TRUSTED" value="false" />
diff --git a/.idea/runConfigurations/run_example_prepare_.xml b/.idea/runConfigurations/run_example_prepare_.xml
index edaca91..e93e309 100644
--- a/.idea/runConfigurations/run_example_prepare_.xml
+++ b/.idea/runConfigurations/run_example_prepare_.xml
@@ -3,6 +3,11 @@
     <module name="bob" />
     <working_directory value="$PROJECT_DIR$/../../alvine/local-dev/components/alvine/apps/test/source" />
     <parameters value="--verbose template prepare --input $PROJECT_DIR$/examples/example2/template/ --output $PROJECT_DIR$/examples/example2/build --data-file=$PROJECT_DIR$/examples/example2/pages/en.yaml" />
+    <envs>
+      <env name="CGO_ENABLED" value="0 " />
+      <env name="CGO_CFLAGS" value="-O2 -U_FORTIFY_SOURCE" />
+      <env name="CGO_LDFLAGS" value="-U_FORTIFY_SOURCE" />
+    </envs>
     <EXTENSION ID="com.fapiko.jetbrains.plugins.better_direnv.runconfigs.GolandRunConfigurationExtension">
       <option name="DIRENV_ENABLED" value="false" />
       <option name="DIRENV_TRUSTED" value="false" />
diff --git a/source/javascript/generate.go b/source/javascript/generate.go
index 4a9e720..44a4ba7 100644
--- a/source/javascript/generate.go
+++ b/source/javascript/generate.go
@@ -41,7 +41,7 @@ func ParseHTMLFile(p string, development bool) error {
 				}
 			}
 
-			if src != "" {
+			if src != "" && source != "" {
 
 				if !path.IsAbs(source) {
 					source = path.Dir(p) + "/" + source
@@ -53,6 +53,11 @@ func ParseHTMLFile(p string, development bool) error {
 
 				}
 
+				if scriptDist == "" || styleDist == "" {
+					log.Error("Missing data-bob-script-dist attribute in script tag")
+					return
+				}
+
 				if !path.IsAbs(scriptDist) {
 					scriptDist = path.Dir(p) + "/" + scriptDist
 				}
-- 
GitLab