Your commit message
This commit is contained in:
parent
023e1049f7
commit
e64c4ead99
|
@ -1 +0,0 @@
|
||||||
_
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$husky_skip_init" ]; then
|
||||||
|
debug () {
|
||||||
|
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly hook_name="$(basename "$0")"
|
||||||
|
debug "starting $hook_name..."
|
||||||
|
|
||||||
|
if [ "$HUSKY" = "0" ]; then
|
||||||
|
debug "HUSKY env variable is set to 0, skipping hook"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f ~/.huskyrc ]; then
|
||||||
|
debug "sourcing ~/.huskyrc"
|
||||||
|
. ~/.huskyrc
|
||||||
|
fi
|
||||||
|
|
||||||
|
export readonly husky_skip_init=1
|
||||||
|
sh -e "$0" "$@"
|
||||||
|
exitCode="$?"
|
||||||
|
|
||||||
|
if [ $exitCode != 0 ]; then
|
||||||
|
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
||||||
|
exit $exitCode
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
|
@ -0,0 +1,29 @@
|
||||||
|
1.Initialize a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
2.Install Husky as a development dependency:
|
||||||
|
npm install husky --save-dev
|
||||||
|
|
||||||
|
3.Enable Husky in your project:
|
||||||
|
npx husky install
|
||||||
|
|
||||||
|
4.Add the following script to your package.json to automatically install Husky hooks after installing dependencies:
|
||||||
|
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "husky install"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
5.Add a pre-commit hook:
|
||||||
|
npx husky add .husky/pre-commit "npm test"
|
||||||
|
|
||||||
|
Pre-commit file
|
||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npm test
|
||||||
|
|
||||||
|
6.Customize pre-commit
|
||||||
|
|
||||||
|
7.Customize package.json
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace application\controllers;
|
// namespace application\controllers;
|
||||||
|
|
||||||
defined('BASEPATH') or exit('No direct script access allowed');
|
defined('BASEPATH') or exit('No direct script access allowed');
|
||||||
class Welcome extends CI_Controller
|
class Welcome extends CI_Controller
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Check phpcs version
|
||||||
|
phpcs --version
|
||||||
|
|
||||||
|
# Check phpcbf version
|
||||||
|
phpcbf --version
|
||||||
|
|
||||||
|
phpcs --standard=PSR12 /path/to/your/test.php
|
||||||
|
phpcbf --standard=PSR12 /path/to/your/test.php
|
||||||
|
|
||||||
|
# Include this path in your settings.json if in case if codesniffer is downloaded locally in a specific project directory
|
||||||
|
executable path
|
||||||
|
"phpcs.executablePath": "~/.config/composer/vendor/bin/phpcs",
|
||||||
|
"phpcbf.executablePath": "~/.config/composer/vendor/bin/phpcbf",
|
||||||
|
|
||||||
|
|
||||||
|
# Install php_codesniffer globally
|
||||||
|
|
||||||
|
composer global require squizlabs/php_codesniffer
|
||||||
|
|
||||||
|
# To add the Composer global bin directory to your PATH
|
||||||
|
|
||||||
|
nano ~/.bashrc
|
||||||
|
|
||||||
|
# Add the following line to include the Composer global bin directory in your PATH:
|
||||||
|
|
||||||
|
export PATH="$PATH:$HOME/.composer/vendor/bin"
|
||||||
|
|
||||||
|
# or for Composer v2.x:
|
||||||
|
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
|
||||||
|
|
||||||
|
# Save the file and reload your shell configuration:
|
||||||
|
source ~/.bashrc
|
Loading…
Reference in New Issue