Skip to content

Commit a254f29

Browse files
authored
Update jsfiddle.sh
I don't wanna talk about it.
1 parent d33efbd commit a254f29

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

samples/jsfiddle.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,34 @@
1111
NAME=$1 # The name of the folder, taken from package.json "build" line.
1212

1313
# /Users/[USERNAME]/git/js-api-samples/samples or similar
14-
SAMPLES_DIR="$(cd "$(dirname "$0")" && pwd)" # Script directory (/samples)
14+
SAMPLES_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # Script directory (/samples)
1515
PROJECT_ROOT=$(dirname "$SAMPLES_DIR") # Get the parent directory (js-api-samples)
1616
DIST_DIR="${PROJECT_ROOT}/dist"
1717

18-
echo "SAMPLES_DIR: ${SAMPLES_DIR}"
19-
echo "PROJECT_ROOT: ${PROJECT_ROOT}"
20-
echo "DIST_DIR: ${DIST_DIR}"
21-
22-
echo "${SAMPLES_DIR}/${NAME}"
23-
2418
# Create a new folder.
25-
mkdir -p ${DIST_DIR}
19+
mkdir -p "${DIST_DIR}/samples/${NAME}/jsfiddle"
2620

2721
# Copy files
22+
echo "Copy ${SAMPLES_DIR}/${NAME}/index.js to ${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
2823
cp "${SAMPLES_DIR}/${NAME}/index.js" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
2924
cp "${SAMPLES_DIR}/${NAME}/index.html" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
3025
cp "${SAMPLES_DIR}/${NAME}/style.css" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
3126

3227
# Remove region tags from files by type, since they all have different comment conventions.
28+
echo "Remove region tags from ${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
3329
sed -i "" "s/\/\/ \[START .*]//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
3430
sed -i "" "s/\/\/ \[END .*]//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.js"
3531

32+
echo "Remove region tags from ${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
3633
sed -i "" "s/<!--\s*\[START .*\]\s*-->//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
3734
sed -i "" "s/<!--\s*\[END .*\]\s*-->//g" "${DIST_DIR}/samples/${NAME}/jsfiddle/index.html"
3835

36+
echo "Remove region tags from ${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
3937
sed -i "" "s/\/\* \[START maps_.*] \*\///g" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
4038
sed -i "" "s/\/\* \[END maps_.*] \*\///g" "${DIST_DIR}/samples/${NAME}/jsfiddle/style.css"
4139

4240
# Generate demo.details.
41+
echo "Generate ${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details"
4342
touch "${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details"
4443
cat > "${DIST_DIR}/samples/${NAME}/jsfiddle/demo.details" << EOF
4544
name: ${NAME}

0 commit comments

Comments
 (0)