Comments (5)
Hello,
It depends which tool you want to make leading I suppose.
I don't know the tool lint-staged, but there might be 2 options:
- the
run
command takes a list of files on STDIN which could be used - You could use the
git:pre-commit
command which uses the changed files only
You could indeed make grumphp leading as well and add a custom bash script. I don't know why the command does not return an exit code of 0
, but that's probably more related to the tool than to grumphp.
from grumphp.
Thanks for your response!
It depends which tool you want to make leading I suppose.
Whichever one will allow me to run both Prettier and GrumPHP 🙂 feels like either approach is close really - I can "almost" run Prettier as a GrumPHP npm task, and I can "almost" run GrumPHP via lint-staged
.
the
run
command takes a list of files on STDIN which could be used
This would be great. Is there any reason GrumPHP currently can't be given paths to run on?
You could use the
git:pre-commit
command which uses the changed files only
Great idea, thanks. Sadly this doesn't work though as lint-staged
still passes the path which causes an error:
[STARTED] Preparing lint-staged...
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] .lintstagedrc.json — 2 files
[STARTED] * — 2 files
[STARTED] *.php — 1 file
[STARTED] prettier --write --ignore-unknown
[STARTED] ./vendor/bin/grumphp git:pre-commit
[FAILED] ./vendor/bin/grumphp git:pre-commit [FAILED]
[FAILED] ./vendor/bin/grumphp git:pre-commit [FAILED]
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[FAILED] prettier --write --ignore-unknown [KILLED]
[FAILED] prettier --write --ignore-unknown [KILLED]
[COMPLETED] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[COMPLETED] Cleaning up temporary files...
✖ ./vendor/bin/grumphp git:pre-commit:
No arguments expected for "git:pre-commit" command, got "/Users/alec/projec
ts/personal/brevwoo/includes/admin.php".
I don't know why the command does not return an exit code of
0
I'm pretty sure Prettier CLI does return an exit code of 0
when it succeeds. In fact even this npm script doesn't work:
parameters:
tasks:
npm_script:
script: "echo 'Hello World'; exit 0"
Which leads me to think npm script tasks aren't working in GrumPHP at all.
from grumphp.
Which leads me to think npm script tasks aren't working in GrumPHP at all.
You are basically running:
npm run "echo 'Hello World'; exit 0"
Which I dont think is supported.
You should run a script that is defined in package.json.
For exampe:
npm run prettier
when the package.json contains:
{
"scripts": {
"prettier": "prettier --check"
}
}
Next, you need to configure grumphp to execute a nmp run task:
grumphp:
tasks:
prettier:
script: "prettier"
triggered_by: [js, jsx, coffee, ts, less, sass, scss]
working_directory: "./"
is_run_task: true
silent: false
metadata:
task: npm_script
If you just want to run a bash command, you need the shell task.
from grumphp.
Ah I see, that makes sense thanks. However in my testing even that is not working 😅
"scripts": {
"prettier": "prettier --check ."
}
parameters:
tasks:
prettier:
script: "prettier"
triggered_by: [js, jsx, coffee, ts, less, sass, scss]
working_directory: "./"
is_run_task: true
silent: false
metadata:
task: npm_script
Running tasks with priority 0!
==============================
Running task 1/7: prettier...
Running task 2/7: phpparser... ✔
Running task 3/7: phpversion... ✔
Running task 4/7: phpcs... ✔
Running task 5/7: phpmd... ✔
Running task 6/7: phpmnd... ✔
Running task 7/7: phpstan... ✔
(same with and without Prettier check errors)
Besides, even if I was able to run Prettier through GrumPHP, it might simplify e.g. CI but it doesn't solve the GrumPHP pre-commit hook not running.
My current lint-staged setup runs all staged files through Prettier on commit. It would be nice to be able to include GrumPHP in that list for *.php
files.
The alternative of removing husky/lint-staged and relying on GrumPHP for commit hooks isn't as appealing. Doesn't look like I would be able to e.g. run only all staged files though Prettier. I think I'd need to run a full prettier --write .
on every commit.
from grumphp.
Closing this issue for now.
Feel free to provide a fix if you can come up with something.
from grumphp.
Related Issues (20)
- PHPMD task does not check all file extensions HOT 5
- Don't do commit message checks on merges? HOT 8
- Memory is not being released in parallel execution HOT 7
- Grumphp running without `.git` folder? HOT 4
- Print the commit message when failing on `git_commit_message` HOT 4
- how can I use grum with docker-compose ? HOT 3
- Fails to Recognize PHPStan Baseline During Commit Workflow
- Override open_basedir only for grumphp test HOT 2
- Grumphp config using default PHPCS XML and other standard's sniff HOT 2
- Undefined constant PhpParser\ParserFactory::PREFER_PHP7 when using `nikic/php-parser` version 5. HOT 1
- Support multiple php versions for tasks HOT 2
- [Task] Add bin/console task for Symfony HOT 1
- The application requires the version "^7.2" or greater. HOT 2
- Support for multiple PHPStan tasks HOT 2
- How do you think about a configuration to opt-in to continue the commit if fixer could fix everything automatically? HOT 2
- DistFileLoader doesn't import another file
- Add support for git_pre_push HOT 1
- git_blacklist never runs? HOT 5
- Composer validate task not running when composer.lock changes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grumphp.