Skip to content

Commit b1d7632

Browse files
committed
Merge pull request #16 from loadsys/b/logic-fix
B/logic fix
2 parents 18d139e + 8625775 commit b1d7632

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

run-in-vagrant

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ if [ "$1" = '-h' ]; then
2222
usage
2323
fi
2424

25-
echo "@TODO: WIP"
26-
exit 1
27-
28-
29-
if mount | grep -q '^/vagrant'; then
25+
VAGRANT_EXEC=$( which vagrant )
26+
VAGRANT_PRESENT=$?
27+
if [ $VAGRANT_PRESENT -eq 0 ] && ! mount | grep -q '^/vagrant'; then
28+
echo '## Running command in vagrant.'
3029
vagrant ssh -c "cd /vagrant; $@"
3130
else
31+
echo '## Running command natively.'
3232
eval "$@"
3333
fi
34+
35+
# Logic matrix:
36+
# vagrant installed + outside vm (no /vagrant mount point) = run in vagrant
37+
# vagrant installed + inside vm = run native
38+
# no vagrant + outside vm = run native
39+
# no vagrant + inside vm = run native

run-tests

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,4 @@ else
3939
fi
4040

4141
bin/clear-cache
42-
if mount | grep -q '^/vagrant'; then
43-
Console/cake test app $TESTCASE --configuration="${PHPUNIT_CONFIG}" "$@"
44-
else
45-
vagrant ssh -c "cd /var/www; Console/cake test app $TESTCASE --configuration="${PHPUNIT_CONFIG}" "$@""
46-
fi
42+
bin/run-in-vagrant "Console/cake test app $TESTCASE --configuration="${PHPUNIT_CONFIG}" "$@""

0 commit comments

Comments
 (0)