Skip to content

Commit

Permalink
💄 Addtional auto-formatting, change configuration generation behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pretzelhands committed Jan 6, 2019
1 parent 1843bac commit a73b11f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions jinx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ function jinx_config_set {
fi
fi

if [[ "$1" == "config_path" ]]
then
local JINX_CONFIG_VALUE=$(echo $2 | sed -e "s#/##g")
fi

grep -q "$1=.*" $JINX_CONFIG_FILE \
&& sed -i -e "s#$1=.*#$1=$JINX_CONFIG_VALUE#" $JINX_CONFIG_FILE \
|| echo "$1=$JINX_CONFIG_VALUE" >> $JINX_CONFIG_FILE
Expand Down Expand Up @@ -280,6 +285,15 @@ function jinx_site_delete {
# Sanity checks
#

# Create configuration file if it doesn't exist.
if [[ ! -f $JINX_CONFIG_FILE ]]
then
echo -e "#\n# .jinxrc\n# Configuration file for jinx\n#\n# Each configuration key must stand on its own line with no comments.\n# The comments above each variable explain their purpose.\n#\n\n# Where you nginx.conf and other files are located. Must end in "/".\nnginx_path=/etc/nginx/\n\n# Where to find the configuration templates for new sites.\n# Gets appended to the nginx path. Must not contain slashes\nconfig_path=configurations\n\n# Which editor to use for editing sites\neditor=nano\n" >> $JINX_CONFIG_FILE
echo -e "${COLOR_YELLOW}First run!${FORMAT_END} Creating default configuration in ~/.jinxrc"
echo "Pardon the interruption, we will now continue running your command."
echo ""
fi

# We require at least one command
if [[ -z "$1" ]]
then
Expand All @@ -296,14 +310,6 @@ then
exit 0
fi

# Create configuration file if it doesn't exist.
if [[ ! -f $JINX_CONFIG_FILE ]]
then
echo -e "#\n# .jinxrc\n# Configuration file for jinx\n#\n# Each configuration key must stand on its own line with no comments.\n# The comments above each variable explain their purpose.\n#\n\n# Where you nginx.conf and other files are located. Must end in "/".\nnginx_path=/etc/nginx/\n\n# Where to find the configuration templates for new sites.\n# Gets appended to the nginx path. Must not contain slashes\nconfig_path=configurations\n\n# Which editor to use for editing sites\neditor=nano\n" >> $JINX_CONFIG_FILE
echo -e "${COLOR_YELLOW}No configuration found.${FORMAT_END} Creating default configuration in ~/.jinxrc"
echo ""
fi

# Process arguments in order
for arg in "$@"
do
Expand Down

0 comments on commit a73b11f

Please sign in to comment.