Skip to content

Configuration

Valentin Berger edited this page Jul 25, 2020 · 1 revision

If you want to copy this project and start playing with it, we recommend you to add the following pre-commit git hook to your project. Please place it under ./.git/hooks/, with the project folder being the current directory.

Note that you may need to change the paths in it.

#!/bin/bash

DARTFMT=/usr/lib/dart/bin/dartfmt
if [[ ! -f $DARTFMT ]]; then
	DARTFMT=/d/Developer/Dart/dart-sdk/bin/dartfmt.bat
fi

$DARTFMT -n --set-exit-if-changed -l 120 .
exit_code=$?
echo "dartfmt exit code: $exit_code"

if [[ $exit_code != 0 ]]; then
	# If it does, fix them, show a warning, and quit (don't commit)
	echo "dartfmt detected lint errors."
	echo "Fixing errors."
	$DARTFMT -w -l 120 .
	echo "Errors fixed. Please commit again."
	exit $exit_code
else
	echo "No lint error detected."
fi

exit 0
Clone this wiki locally