When working in a sub-directory with no composer.json and where a parent directory has a composer.json file, composer will incorrectly present the following prompt when running composer config -gl:
No composer.json in current directory, do you want to use the one at /Volumes/Server? [Y,n]?
The addition of the -n flag silences this, making composer only look at the global composer auth.json file for the credentials as stipulated by the -g flag.
In addition to adding the -n (non-interactive) flag, I've also cleaned up the composer calls to lookup the creds without use of grep or cut. The || true is there to silence any exit codes (and prevent them from bubbling up) similar to how they would have been silenced when running the output through a pipe. And I've cleaned up the odd wrapping of composer in $() on line 95 since this actually results in the output of composer being executed by sh as a command (resulting in an error).
When working in a sub-directory with no composer.json and where a parent directory has a composer.json file, composer will incorrectly present the following prompt when running
composer config -gl
:The addition of the
-n
flag silences this, making composer only look at the global composer auth.json file for the credentials as stipulated by the-g
flag.In addition to adding the
-n
(non-interactive) flag, I've also cleaned up the composer calls to lookup the creds without use of grep or cut. The|| true
is there to silence any exit codes (and prevent them from bubbling up) similar to how they would have been silenced when running the output through a pipe. And I've cleaned up the odd wrapping of composer in$()
on line 95 since this actually results in the output of composer being executed bysh
as a command (resulting in an error).