Last active
February 10, 2017 18:10
-
-
Save greglittlefield-wf/02ad8f731d48e74507d9f372882bb2ea to your computer and use it in GitHub Desktop.
Checks for the presence of the dart2js issue https://github.com/dart-lang/sdk/issues/28727 in a given compiled JS file, and sets the exit code if it is found.
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
#!/usr/bin/env bash | |
# Checks for the presence of the dart2js issue https://github.com/dart-lang/sdk/issues/28727 | |
# in a given compiled JS file, and sets the exit code if it is found. | |
# | |
# For use on `pub build` output, or other output where the dart2js `minify` is enabled. | |
# | |
# Usage: | |
# ./dart-lang_issue_28727_checker.sh <pub_build_output.dart.js> | |
echo '' | |
echo 'Checking whether is affected by dart2js issue https://github.com/dart-lang/sdk/issues/28727' | |
echo '' | |
echo "Searching for duplicate argument names in JS functions in $1..." | |
echo '' | |
grep -E 'function( [a-zA-Z0-9\$_]+)?\(([a-zA-Z0-9\$_]+,)*([a-zA-Z0-9\$_]+),([a-zA-Z0-9\$_]+,)*\3(,[a-zA-Z0-9\$_]+)*\)' "$1" | |
grep_exit_code=$? | |
if [ $grep_exit_code -eq 0 ]; then | |
red=$(tput setaf 1) | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
echo -n "${red}" | |
echo '' | |
echo 'Duplicate argument found. There may be issues present only in minified dart2js code.' | |
echo 'Please reach out in Support: H5 / Dart for instructions on how to proceed.' | |
echo -n "${normal}" | |
echo '' | |
elif [ $grep_exit_code -eq 1 ]; then | |
echo 'Everything looks good!' | |
echo '' | |
echo 'Your minified dart2js should be safe' | |
echo '' | |
exit 0 | |
else | |
echo '' | |
echo 'Something went wrong while grepping' | |
echo '' | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment