Thanks to visit codestin.com
Credit goes to github.com

Skip to content

stubbs: add-module --template pedantic causes error, pedantic unusable #243

@eedwardsav

Description

@eedwardsav

I suspect the pedantic stub \ generate-options and other associated behavior hasn't been used in a while, as it's only referenced in one place, in stubbs/commands/add-module/script

starting at line 86, this code checks if the value of TEMPLATE is exactly equal to pedantic. If so, it sets STUB to the pedantic stub path instead of the regular path.

STUB=$RERUN_MODULE_DIR/lib/stub/bash
if [[ -n "${TEMPLATE:-}" ]]
then
	[[ ${TEMPLATE} == "pedantic" ]] && STUB=$RERUN_MODULE_DIR/lib/stub/bash-pedantic
fi

However, later in the file, starting at line 139, TEMPLATE is again checked and analyzed, this time used to validate if there's a module located at TEMPLATE so it can be cloned.

if [[ -n "${TEMPLATE:-}" ]]
then
    if [[ "$TEMPLATE" =~ [/]+ ]]
    then TEMPLATE_DIR=$(rerun_path_absolute $TEMPLATE)
    else TEMPLATE_DIR=$(rerun_module_exists $TEMPLATE)
    fi
    rerun_log info "Copying files from template: $TEMPLATE..."
    stubbs_module_clone $RERUN_MODULE_HOME_DIR $TEMPLATE_DIR
fi

The problem exists when using --template pedantic to satisfy the former behavior, as it causes an error in the latter behavior on this line:

else TEMPLATE_DIR=$(rerun_module_exists $TEMPLATE)

Because pedantic is not a valid path to a module, rerun_module_exists errors, and you cannot create a module using --template pedantic.

$ RERUN_MODULES=./modules ./rerun stubbs: add-module --module my-module --description "my test module" --template pedantic
ERROR: *** command failed: stubbs:add-module. ***

Possible solution would be to change the second template check to skip if the value is 'pedantic', e.g.:

if [[ -n "${TEMPLATE:-}" && ${TEMPLATE} != "pedantic" ]]
then
    if [[ "$TEMPLATE" =~ [/]+ ]]
    then TEMPLATE_DIR=$(rerun_path_absolute $TEMPLATE)
    else TEMPLATE_DIR=$(rerun_module_exists $TEMPLATE)
    fi
    rerun_log info "Copying files from template: $TEMPLATE..."
    stubbs_module_clone $RERUN_MODULE_HOME_DIR $TEMPLATE_DIR
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions