From 7663e13cee6b26fcfcb5f27610092893800d6080 Mon Sep 17 00:00:00 2001 From: Dashamir Hoxha Date: Tue, 13 Aug 2019 06:12:35 +0200 Subject: [PATCH 1/4] Script that runs 'npx prettier' on all .js and .md files. --- misc/prettier.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 misc/prettier.sh diff --git a/misc/prettier.sh b/misc/prettier.sh new file mode 100755 index 0000000000..3c5511d452 --- /dev/null +++ b/misc/prettier.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Run 'npx prettier' on all .js and .md files. + +cd $(dirname $0) +cd .. + +shopt -s globstar +files=$(npx prettier --list-different src/**/*.js pages/*.js static/**/*.md) +[[ -n $files ]] && npx prettier --write $files + + From 1e15ac66cdfe836a69a8a9884e8120cc5079827b Mon Sep 17 00:00:00 2001 From: Dashamir Hoxha Date: Tue, 13 Aug 2019 08:40:34 +0200 Subject: [PATCH 2/4] Move it to directory 'scripts' --- {misc => scripts}/prettier.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {misc => scripts}/prettier.sh (100%) diff --git a/misc/prettier.sh b/scripts/prettier.sh similarity index 100% rename from misc/prettier.sh rename to scripts/prettier.sh From 04aa7616d7eb4dd9c7cb99976f639de81b24cd7d Mon Sep 17 00:00:00 2001 From: Dashamir Hoxha Date: Tue, 13 Aug 2019 09:14:53 +0200 Subject: [PATCH 3/4] Accept a list of files as arguments --- scripts/prettier.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/prettier.sh b/scripts/prettier.sh index 3c5511d452..d37e643e45 100755 --- a/scripts/prettier.sh +++ b/scripts/prettier.sh @@ -1,11 +1,14 @@ #!/bin/bash -# Run 'npx prettier' on all .js and .md files. +# Run 'npx prettier' on the given .js or .md files. If no files are +# given, run it on all the .js and .md files of the project. cd $(dirname $0) cd .. shopt -s globstar -files=$(npx prettier --list-different src/**/*.js pages/*.js static/**/*.md) -[[ -n $files ]] && npx prettier --write $files +files="$@" +[[ -z $files ]] && files='src/**/*.js pages/*.js static/**/*.md' +fix_files=$(npx prettier --list-different $files) +[[ -n $fix_files ]] && npx prettier --write $fix_files From 3254dbf6bf1e1116687a7f87a7036f62296f28b4 Mon Sep 17 00:00:00 2001 From: Dashamir Hoxha Date: Tue, 13 Aug 2019 09:22:03 +0200 Subject: [PATCH 4/4] Updated doc contributing guide --- static/docs/user-guide/contributing-documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/docs/user-guide/contributing-documentation.md b/static/docs/user-guide/contributing-documentation.md index 62254f2f51..4bc381c2e8 100644 --- a/static/docs/user-guide/contributing-documentation.md +++ b/static/docs/user-guide/contributing-documentation.md @@ -91,7 +91,7 @@ in question. - We use [Prettier](https://prettier.io/) default conventions to format our source code files. The formatting of staged files will automatically be done by the Git pre-commit hook we have configured. You may also run - `npx prettier --write ` manually before committing changes. + `scripts/prettier.sh ` manually before committing changes. - Using `dvc ` in the Markdown files, the docs engine will create a link to that command automatically. (No need to use `[]()` explicitly to