Skip to content

Commit 4905516

Browse files
committed
Complete run-in-vagrant wrapper.
1 parent cc25f30 commit 4905516

1 file changed

Lines changed: 11 additions & 5 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

0 commit comments

Comments
 (0)