# shellcheck shell=dash

___X_CMD_NODE_LOADED=
___x_cmd_node_loaded(){
    [ -n "$___X_CMD_NODE_LOADED" ]
}

___x_cmd_node_load(){
    ! ___x_cmd_node_loaded || return 0

    ___x_cmd_node_load_checkenv || {
        node:debug "Cannot find node installed in this current environment"
        ___x_cmd snap --run node --version >/dev/null
        return
    }

    # TODO: In the future, we need to check the current version is good enough.
    ___X_CMD_NODE_LOADED=1
}


# TODO: Add yes and quiet in the future
___x_cmd_node_load_checkenv(){
    ___x_cmd hascmd node   || return
    ___x_cmd hascmd npm    || return
}
