Skip to content

Commit

Permalink
Correctly test for interactive scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenBoersma committed Sep 4, 2018
1 parent 595b96a commit 0fd8c3d
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 8 deletions.
5 changes: 5 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ init() {

DEV_PHP='php70';

DEV_INTERACTIVE=false;
if [ -t "0" ] && [ -t "1" ]; then
DEV_INTERACTIVE=true;
fi

DEV_SUDO='';
if [ -z "`groups | grep docker`" ]; then
DEV_SUDO='sudo';
Expand Down
4 changes: 3 additions & 1 deletion bin/dev_command/blackfire
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ if [ $? -ne 0 ]; then
fi

dc service blackfireclient;
dc opt '-T';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi
dc opt "--no-deps";

dc cmd blackfire "$@";
Expand Down
4 changes: 3 additions & 1 deletion bin/dev_command/composer
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

dc service ${DEV_PHP};
dc opt '-T';
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi
dc opt "-u $(id -u):$(id -g)"

if [ -n "${DEV_PROJECTPATH}" ]; then
Expand Down
11 changes: 7 additions & 4 deletions bin/dev_command/console
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
fi

if [ -z "$*" ]; then
# Interactive mode
dc cmd "$@";
if [ $# -lt 1 ]; then
dc cmd bash -l;
else
fi

if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
dc cmd "$@";
fi


3 changes: 3 additions & 0 deletions bin/dev_command/custom
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc service ${DEV_PHP};
dc opt "-u $(id -u):$(id -g)"
dc opt "--no-deps";
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/exec
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

dc mode exec;
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ "$1" == "php" ]; then
dc service ${DEV_PHP};
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/git
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc service ${DEV_PHP};
dc opt "-u $(id -u):$(id -g)"
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/logs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

dc mode logs;
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi
dc cmd "$@";

3 changes: 3 additions & 0 deletions bin/dev_command/magerun
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc service ${DEV_PHP};
dc opt "-u $(id -u):$(id -g)"
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/magerun2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc service ${DEV_PHP};
dc opt "-u $(id -u):$(id -g)"
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/myroot
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc yml build/dist/docker-compose-dbclient.yml;
dc service dbclient;
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

dc cmd mysql "-h db -uroot -p${MYSQL_ROOT_PASSWORD} $@";

3 changes: 3 additions & 0 deletions bin/dev_command/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc yml build/dist/docker-compose-dbclient.yml;
dc service dbclient;
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

dc cmd mysql "-h db -u ${USER} $@";

4 changes: 3 additions & 1 deletion bin/dev_command/mysqldump
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

dc yml build/dist/docker-compose-dbclient.yml;
dc opt '-T';
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

dc service 'dbclient';
dc cmd mysqldump "-h db -u ${USER} $@";
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/mytop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc yml build/dist/docker-compose-mytop.yml;
dc service mytop;
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

dc cmd "-h db -u ${USER} -dinformation_schema $@";

5 changes: 4 additions & 1 deletion bin/dev_command/php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

dc service ${DEV_PHP};
dc opt "-u $(id -u):$(id -g)"
dc opt "--no-deps";
dc opt "-u $(id -u):$(id -g)"
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
dc service $1;
shift;
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

if [ -n "${DEV_PROJECTPATH}" ]; then
dc opt "-w /data/${DEV_PROJECTPATH}"
Expand Down
3 changes: 3 additions & 0 deletions bin/dev_command/top
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

dc yml build/dist/docker-compose-ctop.yml
dc opt '--no-deps';
if [ ! ${DEV_INTERACTIVE} ]; then
dc opt '-T';
fi

dc service ctop
dc cmd -s cpu -f ${DEV_PROJECT}
Expand Down

0 comments on commit 0fd8c3d

Please sign in to comment.