Last active
January 3, 2016 03:19
-
-
Save aslushnikov/8401023 to your computer and use it in GitHub Desktop.
A small script to roll CodeMirror.
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
#!/bin/bash | |
set -e | |
function copyFiles | |
{ | |
cd $downstreamFolder | |
for file in *.*; do | |
fileName=$(basename $file) | |
if [[ $fileName == $generatedFile ]]; then | |
continue; | |
fi | |
updatedFile=$(find $upstreamFolder -name $fileName) | |
if [[ -z $updatedFile ]]; then | |
echo "NOT MATCHED $file" | |
continue; | |
fi | |
cp $updatedFile $fileName | |
done; | |
cd $OLDPWD | |
} | |
function generateFile | |
{ | |
# Rolling headlesscodemirror.js | |
runmodeStandaloneFileName="runmode-standalone.js" | |
runmode=$(find $upstreamFolder -name $runmodeStandaloneFileName) | |
if [[ -z $runmode ]]; then | |
echo "Failed to update headlesscodemirror.js" | |
exit 1; | |
fi | |
cd $downstreamFolder | |
echo "// Content of the function is equal to $runmodeStandaloneFileName file | |
// from CodeMirror distribution | |
(function(window) {" > headlesscodemirror.js | |
cat $runmode >> headlesscodemirror.js | |
echo "}(this))" >> headlesscodemirror.js | |
cd $OLDPWD | |
} | |
usage="$(basename $0) [roll|gen] <path-to-upstream-folder> <path-to-downstream-folder>" | |
if (( $# != 3 )); then | |
echo $usage; | |
exit 1; | |
fi | |
generatedFile="headlesscodemirror.js" | |
command=$1 | |
upstreamFolder=$2 | |
downstreamFolder=$3 | |
if [[ $command == "roll" ]]; then | |
copyFiles | |
generateFile | |
elif [[ $command == "gen" ]]; then | |
generateFile | |
else | |
echo $usage | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment