phpro / grumphp

A PHP code-quality tool
MIT License
4.14k stars 430 forks source link

Impossible to run custom NPM scripts #250

Closed Anahkiasen closed 7 years ago

Anahkiasen commented 7 years ago
Q A
Branch 0.11.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets

My configuration

parameters:
    git_dir: .
    bin_dir: ./vendor/bin
    tasks:
        npm_script:
            script: run lint
            triggered_by: [js]
            working_directory: "./"

Steps to reproduce:

Run Grumphp

Result:

In NPM, you can add custom scripts to the package.json file. Custom being any scripts that are not core scripts (npm build, npm test, etc). To run those, you call npm run {name of script}.

Issue is currently Grumphp runs npm 'run lint' instead of npm run lint, which fails.

veewee commented 7 years ago

Thanks @Anahkiasen for reporting this issue. The script parameter is indeed handled as one argument. Possible solutions would be:

Can you tell me which you like best?

Anahkiasen commented 7 years ago

Could Grumphp recognize if the custom script starts with "run "? It's always either going to or not going to anyway no?

veewee commented 7 years ago

That is also a possibility. However, I prefer to keep the configuration explicit. This way, the parameters can't be abused and won't contain any unpredictable logic. Maybe the boolean option is the best choice. As stated in the NPM docs, it is also possible to add custom attributes to a custom command. We could use an arguments parameter for that case.

veewee commented 7 years ago

This issue is fixed in #251. Can you check if this is working for you?