Use overriden composer bin-dir if it exists

Migrated issue

Reported by: dimitriskr

Related to !423 (merged)

Problem/Motivation

A project might have a different bin-dir for its executables (phpcs/phpstan). Check if it exists in the project's composer and use this path for jobs
https://getcomposer.org/doc/06-config.md#bin-dir

Steps to reproduce

Add the following to the composer.json of a project

    "config": {
        "bin-dir": "custom/path/to/bin"
    }

Get the following error
sudo: vendor/bin/phpunit: command not found

Proposed resolution

  1. Change scripts/expand_composer_json.php to check for this [no]
  2. OR create a symlink to the custom path from ./vendor/bin [no]
  3. OR create a variable to hold the full path to the custom directory [yes]

Related issue: Issue #3556609

Related issue: Issue #3557341

Edited by drupalbot