Skip to content

Commit

Permalink
Added support for defaults in init script. (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored May 5, 2024
1 parent 1db74e0 commit 7de5bf2
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,13 @@ replace_string_content() {
set -e
}

to_lowercase() {
echo "${1}" | tr '[:upper:]' '[:lower:]'
}

remove_string_content() {
local token="${1}"
local sed_opts
sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
grep -rI --exclude-dir=".git" --exclude-dir=".idea" --exclude-dir="vendor" --exclude-dir="node_modules" -l "${token}" "$(pwd)" | LC_ALL=C.UTF-8 xargs sed "${sed_opts[@]}" -e "/^${token}/d" || true
}

remove_string_content_line() {
local token="${1}"
local target="${2:-.}"
local sed_opts
sed_opts=(-i) && [ "$(uname)" == "Darwin" ] && sed_opts=(-i '')
grep -rI --exclude-dir=".git" --exclude-dir=".idea" --exclude-dir="vendor" --exclude-dir="node_modules" -l "${token}" "$(pwd)/${target}" | LC_ALL=C.UTF-8 xargs sed "${sed_opts[@]}" -e "/${token}/d" || true
}

remove_tokens_with_content() {
local token="${1}"
local sed_opts
Expand Down Expand Up @@ -239,9 +227,12 @@ main() {
echo

[ -z "${extension_name}" ] && extension_name="$(ask "Name")"
[ -z "${extension_machine_name}" ] && extension_machine_name="$(ask "Machine name")"
[ -z "${extension_type}" ] && extension_type="$(ask "Type: module or theme")"
[ -z "${ci_provider}" ] && ci_provider="$(ask "CI Provider: GitHub Actions or CircleCI")"
extension_machine_name_default="$(convert_string "${extension_name}" "file_name")"
[ -z "${extension_machine_name}" ] && extension_machine_name="$(ask "Machine name" "${extension_machine_name_default}")"
extension_type_default="module"
[ -z "${extension_type}" ] && extension_type="$(ask "Type: module or theme" "${extension_type_default}")"
ci_provider_default="GitHub Actions"
[ -z "${ci_provider}" ] && ci_provider="$(ask "CI Provider: GitHub Actions or CircleCI" "${ci_provider_default}")"

remove_self="$(ask_yesno "Remove this script")"

Expand Down

1 comment on commit 7de5bf2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.