Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing prompt for BLT alias. #201

Merged
merged 2 commits into from
Jun 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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="false"/></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