@@ -20,21 +20,37 @@ _promote_staged_module_main() {
2020 base_name=" $( basename " $sh_file " .sh) "
2121 conf_file=" ./staging/${base_name} .conf"
2222 if [[ -f " $conf_file " ]]; then
23- parent=" $( grep ' ^parent=' " $conf_file " | head -n1 | cut -d= -f2- | xargs) "
24- group=" $( grep ' ^group=' " $conf_file " | head -n1 | cut -d= -f2- | xargs) "
25-
26- if [[ -z " $parent " ]]; then
27- echo " No parent= in $conf_file , skipping $sh_file "
28- continue
23+ parent=" $( grep -Em1 ' ^parent=' " $conf_file " | cut -d= -f2- | xargs) "
24+ group=" $( grep -Em1 ' ^group=' " $conf_file " | cut -d= -f2- | xargs) "
25+ # quick presence/format checks (feature/helpers/description/parent at minimum)
26+ if ! grep -Eqm1 ' ^feature=' " $conf_file " \
27+ || ! grep -Eqm1 ' ^helpers=' " $conf_file " \
28+ || ! grep -Eqm1 ' ^description=' " $conf_file " \
29+ || ! grep -Eqm1 ' ^parent=' " $conf_file " ; then
30+ echo " ERROR: $conf_file missing one or more required fields (feature/helpers/description/parent). Aborting."
31+ exit 1
2932 fi
3033
3134 if [[ -n " $group " ]]; then
3235 dest_dir=" ./src/$parent /$group "
3336 else
3437 dest_dir=" ./src/$parent "
3538 fi
39+ # Fail if parent path does not pre-exist (typo guard)
40+ if [[ ! -d " ./src/$parent " ]]; then
41+ echo " ERROR: Destination './src/$parent ' does not exist. Check 'parent=' in $conf_file ."
42+ exit 1
43+ fi
3644 mkdir -p " $dest_dir "
3745
46+ for f in " $sh_file " " $conf_file " ; do
47+ t=" $dest_dir /$( basename " $f " ) "
48+ if [[ -e " $t " ]]; then
49+ echo " ERROR: Destination already contains $( basename " $f " ) at $dest_dir /. Aborting to prevent overwrite."
50+ exit 1
51+ fi
52+ done
53+
3854 echo " Moving $sh_file and $conf_file to $dest_dir /"
3955 mv " $sh_file " " $dest_dir /"
4056 mv " $conf_file " " $dest_dir /"
0 commit comments