-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocs.sh
More file actions
38 lines (27 loc) · 1.22 KB
/
docs.sh
File metadata and controls
38 lines (27 loc) · 1.22 KB
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
#!/bin/bash
# Copy/generate files for doc snippets.
echo ">>>Running docs.sh"
# Copy static documentation files as part of the build process.
NAME=$1 # The name of the folder, taken from package.json "build" line.
# /Users/[USERNAME]/git/js-api-samples/samples
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # Script directory (/samples)
PROJECT_ROOT=$(dirname "$SCRIPT_DIR") # Get the parent directory (js-api-samples)
DIST_DIR="${PROJECT_ROOT}/dist"
SAMPLE_DIR="${PROJECT_ROOT}/dist/samples/${NAME}"
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
DOCS_DIR="${PROJECT_ROOT}/dist/samples/${NAME}/docs"
# Create a new folder.
mkdir -p ${DOCS_DIR}
# Copy files
cp "${SCRIPT_DIR}/${NAME}/index.ts" "${DOCS_DIR}/index.ts"
cp "${SCRIPT_DIR}/${NAME}/index.js" "${DOCS_DIR}/index.js"
cp "${SCRIPT_DIR}/${NAME}/index.html" "${DOCS_DIR}/index.html"
cp "${SCRIPT_DIR}/${NAME}/style.css" "${DOCS_DIR}/style.css"
# Copy the public folder if one is found (graphics, other static files).
if [ -d "public" ] && [ "$(ls -A public)" ]; then
cp -r public/* "${DOCS_DIR}/"
fi
# Copy the src folder if one is found (.js, .json, anything parseable by Vite).
if [ -d "src" ] && [ "$(ls -A src)" ]; then
cp -r src/* "${DOCS_DIR}/"
fi