Skip to content

Instantly share code, notes, and snippets.

@fatlinesofcode
Last active September 25, 2020 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatlinesofcode/24686ddf8dfdfea5605035c47dec24ec to your computer and use it in GitHub Desktop.
Save fatlinesofcode/24686ddf8dfdfea5605035c47dec24ec to your computer and use it in GitHub Desktop.
lintstaged php-cs-fixer docker config
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