stevegrunwell / wp-enforcer

Git hooks to encourage well-written WordPress.
https://stevegrunwell.com/blog/wp-enforcer/
MIT License
111 stars 14 forks source link

Respect config settings when creating pre-commit hook #39

Open ghost opened 7 years ago

ghost commented 7 years ago

https://github.com/stevegrunwell/wp-enforcer/blob/develop/bin/hooks/pre-commit#L9

This line is hard-coded and does not respect the -c flag of the CLI.

# Determine if we have a phpcs.xml file
if [[ -f ./phpcs.xml ]]; then
    standard="--standard=./phpcs.xml"
else
    standard=''
fi

The above needs to be updated to accept an arg when -c is set in the CLI.

bswatson commented 7 years ago

@jhabdas I wanted to let you know that @stevegrunwell is AFK for the next week, so he may be a bit delayed in his responses.

ghost commented 7 years ago

@bswatson thanks for the heads up. 👌 i'll just keep riffing on my fork and see where I can get

stevegrunwell commented 7 years ago

@jhabdas Mind clarifying which package's -c option you're talking about? Neither WP Enforcer nor PHP_CodeSniffer have a -c, and the hard-coded check is to see whether or not a phpcs.xml file (the filename specified in the PHP_CodeSniffer docs for a default ruleset and the file created when WP Enforcer is installed) exists.

The pre-commit hook is not meant to be run interactively or accept varying options, as it's run automatically when a user attempts to commit to the repository.

Am I missing something here?

ghost commented 7 years ago

-c is the shorthand notation for --config as is currently used in the enforcer CLI IIRC. Hope that helps.