Add build command.
This commit is contained in:
parent
8f2a2d0c2d
commit
593b389ccb
38
isidore.sh
38
isidore.sh
@ -119,6 +119,8 @@ function check_in_project()
|
||||
##
|
||||
function new_project()
|
||||
{
|
||||
echo "$PROJECT_NAME v$ISIDORE_VERSION"
|
||||
|
||||
NEW_PROJECT_DIR=$1
|
||||
NEW_PROJECT_NAME=$2
|
||||
mkdir $NEW_PROJECT_DIR
|
||||
@ -127,9 +129,13 @@ function new_project()
|
||||
echo \
|
||||
"<?php
|
||||
\$site_name = \"$NEW_PROJECT_NAME\";
|
||||
\$author = \"$ISIDORE_AUTHOR_NAME\";
|
||||
\$site_author = \"$ISIDORE_AUTHOR_NAME\";
|
||||
\$site_url = \"\";
|
||||
?>" >> $NEW_PROJECT_DIR/config.php
|
||||
echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version
|
||||
|
||||
echo "New project created."
|
||||
echo "Consider taking a look at the $NEW_PROJECT_DIR/config.php file."
|
||||
}
|
||||
|
||||
##
|
||||
@ -145,11 +151,41 @@ function clean_project()
|
||||
echo "Project cleaned."
|
||||
}
|
||||
|
||||
##
|
||||
# Build the project.
|
||||
##
|
||||
function build_project()
|
||||
{
|
||||
check_in_project
|
||||
|
||||
mkdir -p ./output/
|
||||
WORKDESK="/tmp/isidore-workdesk"
|
||||
CFG_HEADER_FILE="$WORKDESK/config-header.php"
|
||||
mkdir -p $WORKDESK
|
||||
for i in $(find site/ -name '*.php')
|
||||
do
|
||||
echo "<?php include getcwd() . '/config.php'; ?>" > $CFG_HEADER_FILE
|
||||
mkdir -p $WORKDESK/${i%/*}
|
||||
cat $CFG_HEADER_FILE $i > $WORKDESK/$i
|
||||
# the 4 offset is to avoid including `site/`
|
||||
: ${i:4}
|
||||
OUT_DIR="./output/${_%/*}"
|
||||
mkdir -p $OUT_DIR
|
||||
: ${i: :-4}
|
||||
OUT_FILE="$OUT_DIR/${_##*/}"
|
||||
php $WORKDESK/$i > $OUT_FILE
|
||||
done
|
||||
|
||||
rm -r $WORKDESK
|
||||
}
|
||||
|
||||
set_config_vars
|
||||
|
||||
case $1 in
|
||||
new)
|
||||
new_project $2 $3;;
|
||||
build)
|
||||
build_project;;
|
||||
clean)
|
||||
clean_project;;
|
||||
help)
|
||||
|
Loading…
Reference in New Issue
Block a user