Files
odoo_source/addons/web/tooling/enable.sh
T
Samuel Degueldre 92497ed4f1 [FIX] web: fix tooling failing to run due to bash-specific syntax
In #86163 we added a check on the branch name to avoid running the
tooling on stable branches, however this check used bash-specific
syntax. While the hashbang in the pre-commit hook specifies that the
hook should be run using bash, we were using the npm module "husky" to
manage git hooks, which would ignore this hashbang and always run the
hook using sh, causing the hook to fail in all cases.

After some consideration, we have decided to stop using husky, as its
main purpose is to make hook management easier in npm-based projects.
Since we already need a script to enable the tooling, we can do
essentially the same thing that husky is doing but with more control
over the process with no drawbacks.

closes odoo/odoo#87436

X-original-commit: 3104ab16ecf88d4f7b1618db4d62e7f57df34e6c
Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-03-29 12:00:11 +02:00

43 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
community=$(cd -- "$(dirname "$0")" &> /dev/null && cd ../../.. && pwd)
tooling="$community/addons/web/tooling"
enableInDir () {
cd $1
hooksPath="$(realpath --relative-to=. "$tooling/hooks")"
git config core.hooksPath "$hooksPath"
cp "$tooling/_eslintignore" .eslintignore
cp "$tooling/_prettierignore" .prettierignore
cp "$tooling/_eslintrc.json" .eslintrc.json
cp "$tooling/_prettierrc.json" .prettierrc.json
cp "$tooling/_package.json" package.json
if [[ $2 == "copy" ]]; then
# copy over node_modules and package-lock to avoid double "npm install"
cp "$community/package-lock.json" package-lock.json
cp -r "$community/node_modules" node_modules
else
npm install
fi
cd - &> /dev/null
}
read -p "Do you want the tooling installed in enterprise too ? [y, n]" willingToInstallToolingInEnterprise
if [[ $willingToInstallToolingInEnterprise != "n" ]]
then
read -p "What is the relative path from community to enterprise ? (../enterprise)" pathToEnterprise
pathToEnterprise=${pathToEnterprise:-../enterprise}
fi
enableInDir "$community"
if [[ $willingToInstallToolingInEnterprise != "n" ]]
then
enableInDir "$pathToEnterprise" copy
fi
echo ""
echo "JS tooling have been added to the roots"
echo "Make sure to refresh the eslint service and configure your IDE so it uses the config files"
echo 'For VSCode, look inside your .vscode/settings.json file ("editor.defaultFormatter": "dbaeumer.vscode-eslint")'
echo ""