如何将参数传递给自定义作曲家脚本

问题描述

在我的Laravel项目中,我想为一个文件运行PHPunit,就像这样:

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

这是我的作曲家设置:

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

但是,我遇到了这个错误

www @ 287dd7480e22:/ var / www $ composer运行脚本测试tests / Unit / Services / OrderServiceTest.PHP

PHP artisan config:cache --env = testing'tests / Unit / Services / OrderServiceTest.PHP'

参数太多,预期参数为“ command”。

注意:

解决方法

根据this comment in composer repository

如果您执行脚本组并调用多个操作,则无法仅将参数传递给子脚本之一。