-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·28 lines (25 loc) · 916 Bytes
/
pre-commit
File metadata and controls
executable file
·28 lines (25 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -eu
if ! command -v jupyter &> /dev/null
then
echo "ERROR: Cannot find 'jupyter' on your path so the HTML version won't be created/updated automatically"
echo "ERROR: Install 'jupyter' from https://docs.jupyter.org/en/latest/install.html to fix this"
exit 1
elif ! command -v jq &> /dev/null
then
echo "ERROR: Cannot find 'jq' on your path so the HTML version won't be created/updated automatically"
echo "ERROR: Install 'jq' from https://stedolan.github.io/jq/download/ to fix this"
exit 1
else
notebook_paths=`git diff --cached --name-only --diff-filter=d | grep .ipynb; echo ""`
if [ ! -z "$notebook_paths" ]
then
for path in $notebook_paths
do
jupyter nbconvert --to html $path
jupyter nbconvert --clear-output --inplace $path
git add ${path/.ipynb/.html}
git add $path
done
fi
fi