Build and copy paper.js vesrion for docs.

And fix build issues introduced in previous commit: We do need a closure to create local name variables for the callback fucntions.
This commit is contained in:
Jürg Lehni 2016-01-25 11:26:08 +01:00
parent d09459646d
commit 89b3238385
2 changed files with 25 additions and 20 deletions
gulp/tasks

View file

@ -27,14 +27,16 @@ var buildOptions = {
node: { environment: 'node', paperScript: true }
};
var buildNames = Object.keys(buildOptions);
gulp.task('build',
Object.keys(buildOptions).map(function(name) {
buildNames.map(function(name) {
return 'build:' + name;
})
);
for (var key in buildOptions) {
gulp.task('build:' + key, ['clean:build', 'minify:acorn'], function() {
buildNames.forEach(function(name) {
gulp.task('build:' + name, ['clean:build:' + name, 'minify:acorn'], function() {
return gulp.src('src/paper.js')
.pipe(prepro({
// Evaluate constants.js inside the precompilation scope before
@ -46,7 +48,7 @@ for (var key in buildOptions) {
// Note that this would be merge in with already existing
// objects.
return {
__options: extend({}, options, buildOptions[key])
__options: extend({}, options, buildOptions[name])
};
}
}))
@ -58,14 +60,14 @@ for (var key in buildOptions) {
removeTrailing: true
}))
.pipe(rename({
suffix: '-' + key
suffix: '-' + name
}))
.pipe(gulp.dest('dist'));
});
}
gulp.task('clean:build', function() {
return del([
'dist/paper-*.js'
]);
gulp.task('clean:build:' + name, function() {
return del([
'dist/paper-' + name + '.js'
]);
});
});

View file

@ -12,6 +12,7 @@
var gulp = require('gulp'),
del = require('del'),
rename = require('gulp-rename'),
shell = require('gulp-shell'),
options = require('../utils/options.js');
@ -20,22 +21,24 @@ var docOptions = {
server: 'serverdocs' // Generates the website templates for the online docs
};
gulp.task('docs', ['docs:local']);
gulp.task('docs', ['docs:local', 'build:full'], function() {
gulp.src('dist/paper-full.js')
.pipe(rename({ basename: 'paper' }))
.pipe(gulp.dest('dist/docs/assets/js/'));
});
for (var key in docOptions) {
gulp.task('docs:' + key, ['clean:docs:' + key], shell.task([
'java -cp jsrun.jar:lib/* JsRun app/run.js -c=conf/' + key + '.conf ' +
'-D="renderMode:' + docOptions[key] + '" ' +
Object.keys(docOptions).forEach(function(name) {
gulp.task('docs:' + name, ['clean:docs:' + name], shell.task([
'java -cp jsrun.jar:lib/* JsRun app/run.js -c=conf/' + name + '.conf ' +
'-D="renderMode:' + docOptions[name] + '" ' +
'-D="version:' + options.version + '"'
], {
cwd: 'gulp/jsdoc'
}));
}
for (var key in docOptions) {
gulp.task('clean:docs:' + key, function(callback) {
gulp.task('clean:docs:' + name, function() {
return del([
'dist/' + docOptions[key] + '/**',
'dist/' + docOptions[name] + '/**',
]);
});
}
});