1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

Save stats to a json file for deep analysis.

Fixed translate parallel running.
This commit is contained in:
Gunther Brunner 2014-07-03 15:08:18 +09:00
parent ec470a8493
commit fba8586a70

View file

@ -10,6 +10,7 @@ var gettext = require('gulp-angular-gettext')
var jade = require('gulp-jade') var jade = require('gulp-jade')
var clean = require('gulp-clean') var clean = require('gulp-clean')
var protractor = require("gulp-protractor") var protractor = require("gulp-protractor")
var stream = require('stream')
gulp.task('jshint', function () { gulp.task('jshint', function () {
@ -53,6 +54,18 @@ gulp.task('protractor', ['webdriver_update'], function (callback) {
}).on('end', callback) }).on('end', callback)
}) })
// For piping strings
function fromString(filename, string) {
var src = stream.Readable({ objectMode: true })
src._read = function () {
this.push(new gutil.File({
cwd: '', base: '', path: filename, contents: new Buffer(string)
}))
this.push(null)
}
return src
}
// For production // For production
gulp.task("webpack:build", function (callback) { gulp.task("webpack:build", function (callback) {
@ -63,8 +76,8 @@ gulp.task("webpack:build", function (callback) {
"NODE_ENV": JSON.stringify('production') "NODE_ENV": JSON.stringify('production')
} }
}), }),
new webpack.optimize.DedupePlugin(), //new webpack.optimize.DedupePlugin(),
new ngminPlugin(), //new ngminPlugin(),
// TODO: mangle when ngmin works // TODO: mangle when ngmin works
new webpack.optimize.UglifyJsPlugin({mangle: false}) new webpack.optimize.UglifyJsPlugin({mangle: false})
) )
@ -78,6 +91,12 @@ gulp.task("webpack:build", function (callback) {
gutil.log("[webpack:build]", stats.toString({ gutil.log("[webpack:build]", stats.toString({
colors: true colors: true
})) }))
// Save stats to a json file
// Can be analyzed in http://webpack.github.io/analyse/
fromString('stats.json', JSON.stringify(stats.toJson()))
.pipe(gulp.dest('./tmp/'))
callback() callback()
}) })
}) })
@ -110,17 +129,18 @@ gulp.task("webpack:others", function (callback) {
gulp.task('translate', ['jade', 'translate:extract', 'translate:compile']) gulp.task('translate', ['jade', 'translate:extract', 'translate:compile'])
gulp.task('jade', function () { gulp.task('jade', function (cb) {
return gulp.src([ gulp.src([
'./res/**/*.jade' './res/**/*.jade'
, '!./res/bower_components/**' , '!./res/bower_components/**'
]) ])
.pipe(jade()) .pipe(jade())
.pipe(gulp.dest('./tmp/html/')) .pipe(gulp.dest('./tmp/html/'))
cb()
}) })
gulp.task('translate:extract', function () { gulp.task('translate:extract', ['jade'], function (cb) {
return gulp.src([ gulp.src([
'./tmp/html/**/*.html' './tmp/html/**/*.html'
, './res/**/*.js' , './res/**/*.js'
, '!./res/bower_components/**' , '!./res/bower_components/**'
@ -128,14 +148,16 @@ gulp.task('translate:extract', function () {
]) ])
.pipe(gettext.extract('stf.pot')) .pipe(gettext.extract('stf.pot'))
.pipe(gulp.dest('./res/common/lang/po/')) .pipe(gulp.dest('./res/common/lang/po/'))
cb()
}) })
gulp.task('translate:compile', function () { gulp.task('translate:compile', ['translate:extract'], function (cb) {
return gulp.src('./res/common/lang/po/**/*.po') gulp.src('./res/common/lang/po/**/*.po')
.pipe(gettext.compile({ .pipe(gettext.compile({
format: 'json' format: 'json'
})) }))
.pipe(gulp.dest('./res/common/lang/translations/')) .pipe(gulp.dest('./res/common/lang/translations/'))
cb()
}) })
gulp.task('clean', function () { gulp.task('clean', function () {