Reputation: 5765
I'm trying to create a install.sh
script that checks if all my dependencies are installed and then triggers the dependencies scripts.
#!/bin/bash
phpValidation() {
if hash php 2>/dev/null; then
echo 'we have php'
else
echo 'no php'
fi
}
composerValidation() {
if type -t composer ; then #this part does not work
echo 'we have composer'
else
echo 'no composer?!'
fi
}
It works fine for php
and yarn
, but because composer is an alias it does not get trigged through the script.
How can I check if composer is installed and then trigger it?
Upvotes: 0
Views: 7763
Reputation: 529
I found a pretty good script here and modified it to fit my needs.
Here is my simplified version I came up with in the end:
// Check for composer
composer -v > /dev/null 2>&1
COMPOSER=$?
if [[ $COMPOSER -ne 0 ]]; then
echo 'Composer is not installed'
else
echo 'Composer is installed'
fi
Upvotes: 3