Skip to content
Advertisement

How to pass arguments to custom composer script

In my Laravel project, I want to run phpunit for a single file, like this one:

$ composer run-script test tests/Unit/Services/OrderServiceTest.php

Here is my composer setup:

"scripts": {
    "test": [
        "@testenv",
        "@phpunit"
    ],
    "testenv": [
        "php artisan config:cache --env=testing",
        "php artisan config:clear"
    ],
    "phpunit": [
        "php ./vendor/phpunit/phpunit/phpunit --"
    ]
}

However, I’m running into this error:

www@287dd7480e22:/var/www$ composer run-script test tests/Unit/Services/OrderServiceTest.php

php artisan config:cache –env=testing ‘tests/Unit/Services/OrderServiceTest.php’

Too many arguments, expected arguments “command”.

Notice:

Advertisement

Answer

According to this comment in composer repository:

There is no way to pass arguments only to one of the sub-scripts if you do a script group and call multiple things..

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement