diff --git a/build/preprocess.sh b/build/preprocess.sh index 3482a6a2..26c82f7f 100755 --- a/build/preprocess.sh +++ b/build/preprocess.sh @@ -24,10 +24,12 @@ # commented Preprocessed, still formated and commented # stripped Preprocessed, formated but without comments -VERSION=0.8 +# Extract paper.js version from package.json +VERSION=`node -e "process.stdout.write(require('../package.json').version)"` + DATE=$(git log -1 --pretty=format:%ad) -COMMAND="./prepro.js -d '{ \"version\": $VERSION, \"date\": \"$DATE\", \"parser\": \"acorn\", \"svg\": true, \"fatline\": false }' $3 $2" +COMMAND="./prepro.js -d '{ \"version\": \"$VERSION\", \"date\": \"$DATE\", \"parser\": \"acorn\", \"svg\": true, \"fatline\": false }' $3 $2" case $1 in commented) diff --git a/src/core/PaperScope.js b/src/core/PaperScope.js index 5a20c6c3..8818ed7a 100644 --- a/src/core/PaperScope.js +++ b/src/core/PaperScope.js @@ -71,11 +71,11 @@ var PaperScope = Base.extend(/** @lends PaperScope# */{ }, /** - * The version of Paper.js, as a float number. + * The version of Paper.js, as a string. * - * @type Number + * @type String */ - version: /*#=*/ options.version, + version: '/*#=*/ options.version', /** * The currently active project. diff --git a/src/node/index.js b/src/node/index.js index e1659886..d60cab5c 100644 --- a/src/node/index.js +++ b/src/node/index.js @@ -16,8 +16,7 @@ var fs = require('fs'), // Node Canvas library: https://github.com/learnboost/node-canvas Canvas = require('canvas'), jsdom = require('jsdom'), - domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml, - json = require('../../package.json'); + domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml; var options = { parser: 'acorn', @@ -41,7 +40,7 @@ XMLSerializer.prototype.serializeToString = function(node) { var text = domToHtml(node); // Fix a jsdom issue where linearGradient gets converted to lineargradient: // https://github.com/tmpvar/jsdom/issues/620 - return text.replace(/(linear|radial)(gradient)/g, function(all, type) { + return text.replace(/(linear|radial)gradient/g, function(all, type) { return type + 'Gradient'; }); }; @@ -94,8 +93,8 @@ context.PaperScope.inject({ Canvas: Canvas, XMLSerializer: XMLSerializer, DOMParser: DOMParser, - // Also fix version. Remove 2nd dot, so we can make a float out of it: - version: parseFloat(json.version.replace(/(.)(\d)$/, '$2')) + // Also set the correct version from package.json + version: require('../../package.json').version }); require.extensions['.pjs'] = function(module, uri) {