Last active
February 15, 2018 02:05
-
-
Save FMCorz/a5d8b60bd9570ff26ec9556215eb8e71 to your computer and use it in GitHub Desktop.
Moodle Mobile utilities (watch, eslint, ...)
This file contains hidden or 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
module.exports = { | |
"env": { | |
"browser": true, | |
"es6": false | |
}, | |
"extends": "eslint:recommended", | |
"parserOptions": { | |
}, | |
"plugins": [ | |
], | |
"globals": { | |
"angular": true, | |
"moment": true, | |
}, | |
"rules": { | |
"indent": "off", | |
"linebreak-style": [ | |
"error", | |
"unix" | |
], | |
"no-empty": "off", | |
"quotes": [ | |
"error", | |
"single" | |
], | |
"semi": [ | |
"error", | |
"always" | |
] | |
} | |
}; |
This file contains hidden or 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/sh | |
# Script to build a remote add-on from the add-on's directory. | |
# Do we want to move the file somewhere after building it? | |
MOVETO=$1 | |
if [ -n "$MOVETO" ]; then | |
MOVETO=$(readlink -f $MOVETO) | |
fi | |
# Identify the absolute path. | |
ADDONDIR=$(pwd) | |
if [ ! -f "main.js" ]; then | |
echo "You must be in the addon's root folder." | |
exit 2 | |
fi | |
# Navigate to Ionic root. | |
cd ../../../ | |
IONICDIR=$(pwd) | |
if [ ! -f "ionic.project" ]; then | |
echo "Parent path does not look like Moodle Mobile." | |
exit 1 | |
fi | |
# Prepare paths. | |
SCSSFILE="$ADDONDIR/scss/styles.scss" | |
SCSSORIG=${SCSSFILE}.orig | |
ADDONPATH=${ADDONDIR#${IONICDIR}/} | |
ADDONNAME=${ADDONPATH#www/addons/} | |
BUILDFILE=$ADDONDIR/$ADDONNAME.zip | |
# Prepare new styles file. | |
# Replace the variable $mma-<addonname>-path with an empty string, the compiled CSS does not need it. | |
echo "Patching SCSS file" | |
cp $SCSSFILE $SCSSORIG | |
echo '$mma-'$ADDONNAME'-path: "";' > $SCSSFILE | |
cat $SCSSORIG >> $SCSSFILE | |
# Check if an existing build is present. | |
if [ -f $BUILDFILE ]; then | |
echo "Removing previous build file" | |
rm $BUILDFILE | |
fi | |
# Build addon. | |
echo "Building remote addon" | |
gulp remoteaddon -p $ADDONPATH | |
# Restore styles file. | |
echo "Restoring SCSS file" | |
mv $SCSSORIG $SCSSFILE | |
# Done. | |
echo "Remote addon built at:" | |
echo $BUILDFILE | |
# Moving to destination. | |
if [ -n "$MOVETO" ]; then | |
if [ -d "$MOVETO" ]; then | |
MOVETO="$MOVETO/$ADDONNAME.zip" | |
fi | |
if [ -f "$MOVETO" ]; then | |
echo "Moving aborted: the destination file already exists." | |
echo " $MOVETO" | |
exit 3 | |
fi | |
echo "Moving build file to:" | |
echo $MOVETO | |
mv $BUILDFILE $MOVETO | |
fi | |
This file contains hidden or 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 | |
trap 'kill %1; kill %2' SIGINT | |
watchmedo shell-command -R -p '*.js' -c gulp -i 'www/build/*' www/ & | |
watchmedo shell-command -R -p '*.json' -c 'gulp lang' -i 'www/build/*' www/ & | |
ionic serve -b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment