diff --git a/build/build.sh b/build/build.sh index fc73efd7..73816d9a 100755 --- a/build/build.sh +++ b/build/build.sh @@ -30,6 +30,16 @@ then mkdir ../dist/ fi +if [ -f ../dist/paper-full.js ] +then + rm ../dist/paper-full.js +fi + +if [ -f ../dist/paper-node.js ] +then + rm ../dist/paper-node.js +fi + ./preprocess.sh $MODE ../src/paper.js "-i '../src/constants.js'" ../dist/paper-full.js ./preprocess.sh $MODE ../src/paper.js "-o '{ \"paperScript\": false, \"palette\": false }' -i '../src/constants.js'" ../dist/paper-core.js ./preprocess.sh $MODE ../src/paper.js "-o '{ \"environment\": \"node\", \"legacy\": false }' -i '../src/constants.js'" ../dist/paper-node.js diff --git a/build/preprocess.sh b/build/preprocess.sh index eb20a20a..f5610eb2 100755 --- a/build/preprocess.sh +++ b/build/preprocess.sh @@ -26,17 +26,14 @@ # Get the date from the git log: DATE=$(git log -1 --pretty=format:%ad) -# Extract the paper.js version from package.json: -VERSION=$(node -e " - process.stdout.write(require('../package.json').version) -") -# Load and evaluate the __options from options.js, and convert it escaped json: +# Load __options from options.js and convert it to escaped JSON, to be passed on +# to prepro: OPTIONS=$(printf '%q' $(node -e " eval(require('fs').readFileSync('../src/options.js', 'utf8')); process.stdout.write(JSON.stringify(__options)); ")) # Build the prepo.js command out of it, passing on version and date as defines: -COMMAND="../node_modules/.bin/prepro -o $OPTIONS -o '{ \"version\": \"$VERSION\", \"date\": \"$DATE\", \"stats\": false }' $3 $2" +COMMAND="../node_modules/.bin/prepro -o $OPTIONS -o '{ \"date\": \"$DATE\", \"stats\": false }' $3 $2" case $1 in commented) diff --git a/build/publish.sh b/build/publish.sh index 0d8ed6de..3cdba5f4 100755 --- a/build/publish.sh +++ b/build/publish.sh @@ -10,10 +10,23 @@ # # All rights reserved. -# Extract the paper.js version from package.json: -VERSION=$(node -e " - process.stdout.write(require('../package.json').version) -") +# Extract the paper.js version from options.js: +VERSION=$(printf '%q' $(node -e " + eval(require('fs').readFileSync('../src/options.js', 'utf8')); + process.stdout.write(__options.version); +")) + +# Helper function that updates paper.js vesion in JSON files +function update_version() +{ +node -e " + var data = require('$1'); + data.version = '$VERSION'; + require('fs').writeFile('$1', + JSON.stringify(data, null, ' ') + require('os').EOL); +" +} + cd .. PAPER_DIR=`PWD` cd ../paperjs.org @@ -24,6 +37,10 @@ cd $PAPER_DIR/build ./dist.sh cd $PAPER_DIR echo "Commiting Version" +# Update versions +update_version 'package.json' +update_version 'bower.json' +update_version 'component.json' # Add changed json configuration files git add -u package.json git add -u bower.json diff --git a/src/options.js b/src/options.js index 1aa398de..c42d6f1a 100644 --- a/src/options.js +++ b/src/options.js @@ -16,7 +16,7 @@ var __options = { parser: 'acorn', - version: 'dev', + version: '0.9.17', environment: 'browser', legacy: true, stats: true, @@ -28,3 +28,6 @@ var __options = { palette: true, debug: false }; + +if (typeof window === 'object') + __options.version = 'dev';