Last active
December 19, 2015 03:28
-
-
Save AshKyd/5890072 to your computer and use it in GitHub Desktop.
Generate a HTML5 manifest. Optionally checks for a (chrome app) manifest.json and increments version number/timestamp.
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 | |
# Generate a manifest file. Outputs to STDOUT. | |
# Usage: ./manifestgen.sh somefolder/ | |
function scandir { | |
cd $1; | |
RELATIVEDIR=`pwd`; | |
if [ $BASEDIR == $RELATIVEDIR ] | |
then | |
RELATIVEDIR="" | |
else | |
RELATIVEDIR=${RELATIVEDIR:$BASEDIRLEN}/; | |
fi; | |
for f in * | |
do | |
if [ -f "$f" ] | |
then | |
echo "$RELATIVEDIR$f" | |
fi | |
done; | |
for f in * | |
do | |
if [ -d "$f" ] | |
then | |
scandir "$f" | |
fi | |
done; | |
cd ..; | |
} | |
BASEDIR=`cd $1;pwd`; | |
BASEDIRLEN=`expr ${#BASEDIR} + 1`; | |
echo "CACHE MANIFEST"; | |
# Chrome-style manifest.json. Let's print some bits. | |
if [ -f "$BASEDIR/manifest.json" ] | |
then | |
MANIFEST=`cat "$BASEDIR/manifest.json"`; | |
APPNAME=`echo "var p = "$MANIFEST";process.stdout.write(p.name);"|node`; | |
VERSION=`echo "var p = "$MANIFEST";process.stdout.write(p.version);"|node`; | |
echo "# "$APPNAME" version "$VERSION; | |
fi | |
echo "# Manifest dated "`date` | |
scandir $BASEDIR; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment