Skip to content

Commit aededce

Browse files
authored
Ignore symlinks in style checks (#97)
Our style checks were adding problems when adding symlinks to directories: * `prettier` will error out if told to format a directory that doesn't contain any files it can format. * `git` will report new symlinks to directories as new files. * `prettier` will interpret symlinks to directories as directories. * Therefore, if adding a symlink to a directory that doesn't have any `prettier`-relevant files, `prettier` will error out. We avoid this (and any other symlink confusion) by excluding symlinks from style checks. By definition they'll point to a real file or directory that will be getting formatted anyway.
1 parent c9cb16a commit aededce

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

check-style.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ case $1 in
4141
exit 2
4242
esac
4343

44+
# Filter out symlinks from `affected_files`. We'll check the real files.
45+
affected_files=$(echo "$affected_files" | xargs -r -n1 file | grep -v 'symbolic link' | cut -d: -f1 | tr '\n' ' ')
4446

4547
# Unset variable would be a sign of programmer error. We are not using '-e' in
4648
# this script as we'd like to handle these cases ourselves where relevant, i.e.,

0 commit comments

Comments
 (0)