wp-enforcer icon indicating copy to clipboard operation
wp-enforcer copied to clipboard

Respect config settings when creating pre-commit hook

Open ghost opened this issue 7 years ago • 4 comments

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.

ghost avatar May 20 '17 14:05 ghost

@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.

bswatson avatar May 20 '17 15:05 bswatson

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

ghost avatar May 20 '17 15:05 ghost

@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?

stevegrunwell avatar May 28 '17 18:05 stevegrunwell

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

ghost avatar May 28 '17 20:05 ghost