diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js index 1dd9f34e..4f912b69 100644 --- a/gulp/tasks/build.js +++ b/gulp/tasks/build.js @@ -15,6 +15,7 @@ var gulp = require('gulp'), rename = require('gulp-rename'), uncomment = require('gulp-uncomment'), whitespace = require('gulp-whitespace'), + del = require('del'), extend = require('extend'), options = require('../utils/options.js'); @@ -26,16 +27,14 @@ var buildOptions = { node: { environment: 'node', paperScript: true } }; -var buildNames = Object.keys(buildOptions); - gulp.task('build', - buildNames.map(function(name) { + Object.keys(buildOptions).map(function(name) { return 'build:' + name; }) ); -buildNames.forEach(function(name) { - gulp.task('build:' + name, ['clean:build', 'minify:acorn'], function() { +for (var key in buildOptions) { + gulp.task('build:' + key, ['clean:build', 'minify:acorn'], function() { return gulp.src('src/paper.js') .pipe(prepro({ // Evaluate constants.js inside the precompilation scope before @@ -47,7 +46,7 @@ buildNames.forEach(function(name) { // Note that this would be merge in with already existing // objects. return { - __options: extend({}, options, buildOptions[name]) + __options: extend({}, options, buildOptions[key]) }; } })) @@ -59,8 +58,14 @@ buildNames.forEach(function(name) { removeTrailing: true })) .pipe(rename({ - suffix: '-' + name + suffix: '-' + key })) .pipe(gulp.dest('dist')); }); +} + +gulp.task('clean:build', function() { + return del([ + 'dist/paper-*.js' + ]); }); diff --git a/gulp/tasks/clean.js b/gulp/tasks/clean.js deleted file mode 100644 index 0b0c4a01..00000000 --- a/gulp/tasks/clean.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. - * http://paperjs.org/ - * - * Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey - * http://scratchdisk.com/ & http://jonathanpuckey.com/ - * - * Distributed under the MIT license. See LICENSE file for details. - * - * All rights reserved. - */ - -var gulp = require('gulp'), - del = require('del'); - -gulp.task('clean:build', function() { - return del([ - 'dist/paper-*.js' - ]); -}); - -gulp.task('clean:docs', function(callback) { - return del([ - 'dist/docs/**', - 'dist/serverdocs/**' - ]); -}); - -gulp.task('clean:load', function() { - return del([ - 'dist/paper-full.js', - 'dist/paper-node.js' - ]); -}); diff --git a/gulp/tasks/docs.js b/gulp/tasks/docs.js index 7d41b7cf..55d5cda0 100644 --- a/gulp/tasks/docs.js +++ b/gulp/tasks/docs.js @@ -20,14 +20,22 @@ var docOptions = { server: 'serverdocs' // Generates the website templates for the online docs }; -Object.keys(docOptions).forEach(function(name) { - gulp.task('docs:' + name, ['clean:docs'], shell.task([ - 'java -cp jsrun.jar:lib/* JsRun app/run.js -c=conf/' + name + '.conf ' + - '-D="renderMode:' + docOptions[name] + '" ' + +gulp.task('docs', ['docs:local']); + +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] + '" ' + '-D="version:' + options.version + '"' ], { cwd: 'gulp/jsdoc' })); -}); +} -gulp.task('docs', ['docs:local']); +for (var key in docOptions) { + gulp.task('clean:docs:' + key, function(callback) { + return del([ + 'dist/' + docOptions[key] + '/**', + ]); + }); +} diff --git a/gulp/tasks/load.js b/gulp/tasks/load.js index c33e4165..b1ceff99 100644 --- a/gulp/tasks/load.js +++ b/gulp/tasks/load.js @@ -19,3 +19,10 @@ gulp.task('load', ['clean:load'], function() { .pipe(symlink('dist/paper-full.js')) .pipe(symlink('dist/paper-node.js')); }); + +gulp.task('clean:load', function() { + return del([ + 'dist/paper-full.js', + 'dist/paper-node.js' + ]); +});