Skip to content

Commit

Permalink
Fixing prompt for BLT alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Jun 23, 2016
1 parent 1ec9baa commit eeb239a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 1 addition & 5 deletions template/build/core/phing/tasks/blt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
</target>

<target name="blt:alias" description="Installs the BLT alias for command line usage.">
<!-- @todo Check to see if alias is already present. -->
<echo>BLT can automatically create a Bash alias to make it easier to run BLT tasks.</echo>
<echo>This alias may be created in .bash_profile or .bashrc depending on your system architecture.</echo>
<propertyprompt propertyName="create_alias" defaultValue="y" useExistingValue="true" promptText="Create a bash alias now? (y/n)" />
<if>
<equals arg1="${create_alias}" arg2="y"/>
<not><equals arg1="${create_alias}" arg2="n"/></not>
<then>
<exec dir="${repo.root}/scripts/blt" command="./install-alias.sh" passthru="true" checkreturn="true"/>
</then>
Expand Down
25 changes: 19 additions & 6 deletions template/scripts/blt/install-alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,27 @@ if [ ! -z "$DETECTED_PROFILE" ]; then
echo "Alias for blt already exists in $DETECTED_PROFILE"
exit
fi
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

if cat $DIR/alias >> $DETECTED_PROFILE; then
echo "Added alias for blt to $DETECTED_PROFILE"
echo "Restart your terminal session to use the new command."
else
echo "Error: Could not modify $DETECTED_PROFILE."
echo "BLT can automatically create a Bash alias to make it easier to run BLT tasks."
echo "This alias may be created in .bash_profile or .bashrc depending on your system architecture."
echo ""
read -p "Install alias? (y/n)" -n 1 -r
echo ""

if [[ $REPLY =~ ^[Yy]$ ]]; then
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

if cat $DIR/alias >> $DETECTED_PROFILE; then
echo "Added alias for blt to $DETECTED_PROFILE"
echo "You may now use the 'blt' command from anywhere within a BLT-generated repository."
echo ""
echo "Restart your terminal session to use the new command."
else
echo "Error: Could not modify $DETECTED_PROFILE."
fi

fi

else
echo "Could not install blt alias. No profile found. Tried ~/.zshrc, ~/.bashrc, ~/.bash_profile and ~/.profile."
fi

0 comments on commit eeb239a

Please sign in to comment.