chore: use load-plugins to make gulpfile shorter
This commit is contained in:
parent
3d05f521fe
commit
2797075200
28
gulpfile.js
28
gulpfile.js
|
@ -1,24 +1,18 @@
|
||||||
var benchpress = require('angular-benchpress/lib/cli');
|
var benchpress = require('angular-benchpress/lib/cli');
|
||||||
var clean = require('gulp-rimraf');
|
|
||||||
var connect = require('gulp-connect');
|
|
||||||
var ejs = require('gulp-ejs');
|
|
||||||
var es = require('event-stream');
|
var es = require('event-stream');
|
||||||
var file2moduleName = require('./file2modulename');
|
var file2moduleName = require('./file2modulename');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var glob = require('glob');
|
var glob = require('glob');
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
|
var $ = require('gulp-load-plugins')();
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
var mergeStreams = require('event-stream').merge;
|
var mergeStreams = require('event-stream').merge;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var Q = require('q');
|
var Q = require('q');
|
||||||
var readline = require('readline');
|
var readline = require('readline');
|
||||||
var rename = require('gulp-rename');
|
|
||||||
var runSequence = require('run-sequence');
|
var runSequence = require('run-sequence');
|
||||||
var shell = require('gulp-shell');
|
|
||||||
var spawn = require('child_process').spawn;
|
var spawn = require('child_process').spawn;
|
||||||
var through2 = require('through2');
|
var through2 = require('through2');
|
||||||
var watch = require('gulp-watch');
|
|
||||||
var changed = require('gulp-changed');
|
|
||||||
|
|
||||||
var js2es5Options = {
|
var js2es5Options = {
|
||||||
sourceMaps: true,
|
sourceMaps: true,
|
||||||
|
@ -88,7 +82,7 @@ var sourceTypeConfigs = {
|
||||||
|
|
||||||
gulp.task('modules/clean', function() {
|
gulp.task('modules/clean', function() {
|
||||||
return gulp.src('build', {read: false})
|
return gulp.src('build', {read: false})
|
||||||
.pipe(clean());
|
.pipe($.rimraf());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('modules/build.dart/src', function() {
|
gulp.task('modules/build.dart/src', function() {
|
||||||
|
@ -99,7 +93,7 @@ gulp.task('modules/build.dart/pubspec', function() {
|
||||||
var outputDir = sourceTypeConfigs.dart.outputDir;
|
var outputDir = sourceTypeConfigs.dart.outputDir;
|
||||||
var files = [];
|
var files = [];
|
||||||
var changedStream = gulp.src('modules/*/pubspec.yaml')
|
var changedStream = gulp.src('modules/*/pubspec.yaml')
|
||||||
.pipe(changed(outputDir)) // Only forward files that changed.
|
.pipe($.changed(outputDir)) // Only forward files that changed.
|
||||||
.pipe(through2.obj(function(file, enc, done) {
|
.pipe(through2.obj(function(file, enc, done) {
|
||||||
files.push(path.resolve(process.cwd(), outputDir, file.relative));
|
files.push(path.resolve(process.cwd(), outputDir, file.relative));
|
||||||
this.push(file);
|
this.push(file);
|
||||||
|
@ -160,19 +154,19 @@ function renameEs5ToJs(file) {
|
||||||
|
|
||||||
function createModuleTask(sourceTypeConfig) {
|
function createModuleTask(sourceTypeConfig) {
|
||||||
var transpile = gulp.src(sourceTypeConfig.transpileSrc)
|
var transpile = gulp.src(sourceTypeConfig.transpileSrc)
|
||||||
.pipe(rename({extname: '.'+sourceTypeConfig.outputExt}))
|
.pipe($.rename({extname: '.'+sourceTypeConfig.outputExt}))
|
||||||
.pipe(rename(renameSrcToLib))
|
.pipe($.rename(renameSrcToLib))
|
||||||
.pipe(gulpTraceur(sourceTypeConfig.compilerOptions, file2moduleName))
|
.pipe(gulpTraceur(sourceTypeConfig.compilerOptions, file2moduleName))
|
||||||
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
||||||
var copy = gulp.src(sourceTypeConfig.copySrc)
|
var copy = gulp.src(sourceTypeConfig.copySrc)
|
||||||
.pipe(rename(renameSrcToLib))
|
.pipe($.rename(renameSrcToLib))
|
||||||
.pipe(rename(renameEs5ToJs))
|
.pipe($.rename(renameEs5ToJs))
|
||||||
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
||||||
// TODO: provide the list of files to the template
|
// TODO: provide the list of files to the template
|
||||||
// automatically!
|
// automatically!
|
||||||
var html = gulp.src(sourceTypeConfig.htmlSrc)
|
var html = gulp.src(sourceTypeConfig.htmlSrc)
|
||||||
.pipe(rename(renameSrcToLib))
|
.pipe($.rename(renameSrcToLib))
|
||||||
.pipe(ejs({
|
.pipe($.ejs({
|
||||||
type: sourceTypeConfig.outputExt
|
type: sourceTypeConfig.outputExt
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
||||||
|
@ -275,7 +269,7 @@ gulp.task('benchmarks/build.js', function() {
|
||||||
gulp.task('benchmarks/build.dart2js.dart', function () {
|
gulp.task('benchmarks/build.dart2js.dart', function () {
|
||||||
return gulp.src([
|
return gulp.src([
|
||||||
"build/dart/benchmarks/lib/**/benchmark.dart"
|
"build/dart/benchmarks/lib/**/benchmark.dart"
|
||||||
]).pipe(shell(['dart2js --package-root="build/dart/benchmarks/packages" -o "<%= file.path %>.js" <%= file.path %>']));
|
]).pipe($.shell(['dart2js --package-root="build/dart/benchmarks/packages" -o "<%= file.path %>.js" <%= file.path %>']));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('benchmarks/create-bpconf.dart', function () {
|
gulp.task('benchmarks/create-bpconf.dart', function () {
|
||||||
|
@ -313,7 +307,7 @@ gulp.task('benchmarks/build.dart', function() {
|
||||||
// WEB SERVERS
|
// WEB SERVERS
|
||||||
|
|
||||||
gulp.task('serve', function() {
|
gulp.task('serve', function() {
|
||||||
connect.server({
|
$.connect.server({
|
||||||
root: [__dirname+'/build'],
|
root: [__dirname+'/build'],
|
||||||
port: 8000,
|
port: 8000,
|
||||||
livereload: false,
|
livereload: false,
|
||||||
|
|
14
package.json
14
package.json
|
@ -11,11 +11,6 @@
|
||||||
"es6-module-loader": "^0.9.2",
|
"es6-module-loader": "^0.9.2",
|
||||||
"systemjs": "^0.9.1",
|
"systemjs": "^0.9.1",
|
||||||
"angular-benchpress": "^0.1.3",
|
"angular-benchpress": "^0.1.3",
|
||||||
"gulp": "^3.8.8",
|
|
||||||
"gulp-changed": "^1.0.0",
|
|
||||||
"gulp-rename": "^1.2.0",
|
|
||||||
"gulp-watch": "^1.0.3",
|
|
||||||
"gulp-shell": "^0.2.10",
|
|
||||||
"karma-cli": "^0.0.4",
|
"karma-cli": "^0.0.4",
|
||||||
"karma": "^0.12.23",
|
"karma": "^0.12.23",
|
||||||
"karma-chrome-launcher": "^0.1.4",
|
"karma-chrome-launcher": "^0.1.4",
|
||||||
|
@ -29,7 +24,14 @@
|
||||||
"gulp-rimraf": "^0.1.0",
|
"gulp-rimraf": "^0.1.0",
|
||||||
"run-sequence": "^0.3.6",
|
"run-sequence": "^0.3.6",
|
||||||
"glob": "^4.0.6",
|
"glob": "^4.0.6",
|
||||||
"gulp-ejs": "^0.3.1",
|
|
||||||
"traceur": "0.0.74"
|
"traceur": "0.0.74"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp": "^3.8.8",
|
||||||
|
"gulp-changed": "^1.0.0",
|
||||||
|
"gulp-rename": "^1.2.0",
|
||||||
|
"gulp-shell": "^0.2.10",
|
||||||
|
"gulp-load-plugins": "^0.7.1",
|
||||||
|
"gulp-ejs": "^0.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue