Last active
September 25, 2020 00:31
-
-
Save fatlinesofcode/24686ddf8dfdfea5605035c47dec24ec to your computer and use it in GitHub Desktop.
lintstaged php-cs-fixer docker config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const phpCsfixer = 'docker exec -i lep php ./vendor/bin/php-cs-fixer' | |
const toRelativePath = (absolutePaths) => { | |
const cwd = process.cwd() | |
const relativePaths = absolutePaths.map((file) => path.relative(cwd, file)) | |
return relativePaths.join(' ') | |
} | |
/** | |
* test run $ npm run lint-staged | |
*/ | |
module.exports = { | |
'**/*.php': absolutePaths => { | |
const paths = toRelativePath(absolutePaths) | |
return [ | |
`${phpCsfixer} fix --config .php_cs --path-mode=intersection --using-cache=no ${paths}`, // auto-fix | |
`${phpCsfixer} fix --config .php_cs --path-mode=intersection --using-cache=no --dry-run ${paths}`, //throw exit-code for errors | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment