Share one options.js file describing Paper.js options for Node.js, build.sh and the dev version.

This commit is contained in:
Jürg Lehni 2013-05-27 15:11:32 -07:00
parent 2a75b04af0
commit d577b1bf48
4 changed files with 44 additions and 22 deletions

View file

@ -24,10 +24,19 @@
# commented Preprocessed, still formated and commented
# stripped Preprocessed, formated but without comments
# Extract paper.js version from package.json
VERSION=$(node -e "process.stdout.write(require('../package.json').version)")
# Get the date from the git log:
DATE=$(git log -1 --pretty=format:%ad)
COMMAND="./prepro.js -d '{ \"version\": \"$VERSION\", \"date\": \"$DATE\", \"parser\": \"acorn\", \"svg\": true, \"fatline\": false }' $3 $2"
# 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 an escaped json:
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="./prepro.js -d $OPTIONS -d '{ \"version\": \"$VERSION\", \"date\": \"$DATE\" }' $3 $2"
case $1 in
commented)

View file

@ -14,17 +14,7 @@
// 'preprocess' it on the fly in the browser, avoiding the step of having to
// manually preprocess it after each change.
// Define options for compile-time preprocessing.
var options = {
parser: 'acorn',
version: 'dev',
browser: true,
stats: true,
svg: true,
fatline: true,
debug: false
};
// This folder is specified relatively to the lib folder from which prepro.js is
// loaded, and which is referenced as the root.
include('../src/options.js');
include('../src/paper.js');

View file

@ -18,14 +18,13 @@ var fs = require('fs'),
jsdom = require('jsdom'),
domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml;
var options = {
parser: 'acorn',
// Use 'dev' for on-the fly compilation of separate files ,but update after.
version: 'dev',
server: true,
svg: true,
fatline: false
};
// Load the options from load.js, but evaluate into local scope:
eval(fs.readFileSync(path.resolve(__dirname, '../options.js'), 'utf8'));
// Change node.js specific settings. Use 'dev' version for on-the fly
// compilation of separate files, and set to correct value after.
options.version = 'dev';
options.browser = false;
options.server = true;
// Create a document and a window using jsdom, e.g. for exportSVG()
var doc = jsdom.jsdom("<html><body></body></html>"),

24
src/options.js Normal file
View file

@ -0,0 +1,24 @@
/*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
// Define default options for compile-time preprocessing. These are also used
// for building, but some values are overridden (e.g. version, stats).
var options = {
parser: 'acorn',
version: 'dev',
browser: true,
stats: true,
svg: true,
fatline: false,
debug: false
};