-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that the build has min.js files before generating the .zip file (
#2149) * Ensure that the build has min.js files before generating the .zip file * improve error message
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Initialize the error flag | ||
error_flag=0 | ||
|
||
# Define the base directory to check | ||
base_dir="./assets" | ||
|
||
# Check if the base directory exists | ||
if [ ! -d "$base_dir" ]; then | ||
echo "Error: The directory $base_dir does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Function to check for corresponding .min.js file | ||
check_for_min_js() { | ||
local js_file="$1" | ||
local min_js_file="${js_file%.js}.min.js" | ||
if [ ! -f "$min_js_file" ]; then | ||
echo "Error: No corresponding .min.js file found for $js_file" | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
# Find all .js files within the base directory (excluding .min.js files) | ||
while IFS= read -r -d '' js_file; do | ||
if ! check_for_min_js "$js_file"; then | ||
error_flag=1 | ||
fi | ||
done < <(find "$base_dir" -type f -name "*.js" ! -name "*.min.js" -print0) | ||
|
||
# Exit with an error code if any .js file is missing its corresponding .min.js file | ||
if [ "$error_flag" -ne 0 ]; then | ||
echo "Error: the ZIP could not be built because minified scripts are missing. Please ensure you are using the correct versions of NPM and Node.js." | ||
exit 1 | ||
else | ||
echo "All .js files within $base_dir have corresponding .min.js files." | ||
exit 0 | ||
fi |