如何使composer.json脚本接受标志

问题描述 投票:0回答:1

我无法在我的--filter脚本中添加composer.json参数。

我一直在读the docs,但我似乎无法弄明白。

我的composer.json中有以下脚本

"scripts": {
    "test": [
        ".\\vendor\\bin\\phpunit"
    ]
},

但我不能发送任何--filters像:

$ composer test --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP

这会导致以下错误:

[Symfony\Component\Console\Exception\RuntimeException]  
  The "--filter" option does not exist.

知道如何让脚本接受--filter参数吗?

我希望能够更快地运行它,然后总是打字

.\\vendor\\bin\\phpunit
composer-php
1个回答
0
投票

这里的关键是仔细阅读文档。在文档中有:

与run-script命令类似,您可以为脚本提供其他参数,例如作曲家测试 - --filter会将--filter传递给phpunit脚本。

所以要通过--filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP你应该运行:

composer test -- --filter pigeon_ringnumber_cant_be_more_then_9_chars_for_BE_NL_ESP

所以你应该在指定你要传递的参数之前使用额外的--

当然,在这种情况下,您搜索的解决方案可能会简单得多。你可以考虑creating symbolic link这样做。

© www.soinside.com 2019 - 2024. All rights reserved.