Skip to content

Commit d33efbd

Browse files
committed
fix: Fixes problems with jsfiddle generation script.
1 parent 04249d3 commit d33efbd

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

samples/jsfiddle.sh

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,43 @@
1010
# Generate JSFiddle output as part of the build process.
1111
NAME=$1 # The name of the folder, taken from package.json "build" line.
1212

13-
# Relative path to the top-level of the examples folder.
14-
#PATH_TO_DOCS=/Users/[USERNAME]/git/js-api-samples/samples
15-
PATH_TO_DOCS="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
13+
# /Users/[USERNAME]/git/js-api-samples/samples or similar
14+
SAMPLES_DIR="$(cd "$(dirname "$0")" && pwd)" # Script directory (/samples)
15+
PROJECT_ROOT=$(dirname "$SAMPLES_DIR") # Get the parent directory (js-api-samples)
16+
DIST_DIR="${PROJECT_ROOT}/dist"
1617

17-
OUTPUT_DIR=${PATH_TO_DOCS}
18-
DIST_DIR="../../dist/samples/${NAME}/jsfiddle"
18+
echo "SAMPLES_DIR: ${SAMPLES_DIR}"
19+
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
20+
echo "DIST_DIR: ${DIST_DIR}"
21+
22+
echo "${SAMPLES_DIR}/${NAME}"
1923

2024
# Create a new folder.
2125
mkdir -p ${DIST_DIR}
2226

2327
# Copy files
24-
cp "${OUTPUT_DIR}/${NAME}/index.js" "${DIST_DIR}/index.js"
25-
cp "${OUTPUT_DIR}/${NAME}/index.html" "${DIST_DIR}/index.html"
26-
cp "${OUTPUT_DIR}/${NAME}/style.css" "${DIST_DIR}/style.css"
28+
cp "${SAMPLES_DIR}/${NAME}/index.js" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
29+
cp "${SAMPLES_DIR}/${NAME}/index.html" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
30+
cp "${SAMPLES_DIR}/${NAME}/style.css" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
2731

2832
# Remove region tags from files by type, since they all have different comment conventions.
29-
sed -i "" "s/\/\/ \[START .*]//g" "${DIST_DIR}/index.js"
30-
sed -i "" "s/\/\/ \[END .*]//g" "${DIST_DIR}/index.js"
33+
sed -i "" "s/\/\/ \[START .*]//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
34+
sed -i "" "s/\/\/ \[END .*]//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
3135

32-
sed -i "" "s/<!--\s*\[START .*\]\s*-->//g" "${DIST_DIR}/index.html"
33-
sed -i "" "s/<!--\s*\[END .*\]\s*-->//g" "${DIST_DIR}/index.html"
36+
sed -i "" "s/<!--\s*\[START .*\]\s*-->//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
37+
sed -i "" "s/<!--\s*\[END .*\]\s*-->//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
3438

35-
sed -i "" "s/\/\* \[START maps_.*] \*\///g" "${DIST_DIR}/style.css"
36-
sed -i "" "s/\/\* \[END maps_.*] \*\///g" "${DIST_DIR}/style.css"
39+
sed -i "" "s/\/\* \[START maps_.*] \*\///g" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
40+
sed -i "" "s/\/\* \[END maps_.*] \*\///g" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
3741

3842
# Generate demo.details.
39-
touch "${DIST_DIR}/demo.details"
40-
cat > "${DIST_DIR}/demo.details" << EOF
43+
touch "${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details"
44+
cat > "${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details" << EOF
4145
name: ${NAME}
4246
authors:
4347
- Geo Developer IX Documentation Team
44-
tags:
48+
tags:s
4549
- google maps
4650
load_type: h
47-
description: Sample code for Google Maps Platform JavaScript API
48-
EOF
51+
description: Sample code supporting Google Maps Platform JavaScript API documentation.
52+
EOF

0 commit comments

Comments
 (0)