-
Notifications
You must be signed in to change notification settings - Fork 0
/
postbuild.sh
executable file
·48 lines (33 loc) · 1.08 KB
/
postbuild.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
echo "Move assets from public/prefix to public/"
# ================================================================ #
# Create a temporary directory that is cleaned up after exit.
# Copied from: https://stackoverflow.com/a/34676160
#
# the temp directory used
WORK_DIR=$(mktemp -d)
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
rm -rf /public/prefix
echo "Deleted temp working directory $WORK_DIR"
}
# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
# ================================================================ #
echo "pwd"
pwd
echo "Move files from public/ to $WORK_DIR"
mv public/prefix/* "$WORK_DIR"
echo "Move files from $WORK_DIR to public/docs"
mv "$WORK_DIR"/* public/
echo "Assets moved to public/docs"
# This wont be needed on Vercel and will probably cause an error during build once _redirects is gone
echo "Copying _redirects file to public/"
cp _redirects public/