Move clear tasks to the task files they relate to.

This commit is contained in:
Jürg Lehni 2016-01-25 11:06:45 +01:00
parent 3a45d36224
commit d09459646d
4 changed files with 33 additions and 47 deletions

View file

@ -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'
]);
});

View file

@ -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'
]);
});

View file

@ -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] + '/**',
]);
});
}

View file

@ -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'
]);
});