I have an analysis script (phan/phan) that I'd like to run on all my staged files. However, the way I'd do this would be with the command:
./vendor/bin/phan -p --include-analysis-file-list file1.php,file2.php,file3.php
... where fileX.php are the staged files.
If I set my lint-staged configuration like the following, then it only analyzes the first file, because lint-stage passes in the list of files space separated.
"*.php": [
"./vendor/bin/phan -p --include-analysis-file-list",
"git add"
]
Is there a way to get a comma-separated list of the staged files instead? And, ideally, this would be configurable per linter (since I still want my eslint config to work).
Thanks!
lint-staged: 7.2.0That sounds like a duplicate of #138 to me. Please chime in and add your opinion. Plus we had this https://github.com/okonet/lint-staged/pull/221 but I'm not sure it's the right approach. Please review it and let us know what you think there.
Sounds good.
For anyone searching and looking for a quick solution, this is what I implemented:
_package.json:_
"lint-staged": {
"linters": {
"*.php": [
"./phan-wrapper.sh",
"git add"
]
}
}
_phan-wrapper.sh:_
# convert argument list to comma-separated string
OLDIFS=$IFS
IFS=","
CSV_FILES=$*
IFS=$OLDIFS
# run task
./vendor/bin/phan -p --include-analysis-file-list "${CSV_FILES}"
Most helpful comment
Sounds good.
For anyone searching and looking for a quick solution, this is what I implemented:
_package.json:_
_phan-wrapper.sh:_