This repository has been archived by the owner on Jul 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 483
/
gulpfile.js
81 lines (65 loc) · 2.06 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var fs = require('fs');
var gulp = require('gulp');
var jasmine = require('gulp-jasmine');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var merge = require('merge-stream');
var gloablizationDir = 'src/globalization/';
var basefiles = ['src/core.js','src/sugarpak.js','src/parser.js','src/time.js'];
var corefiles = [gloablizationDir+'en-US.js'].concat(basefiles);
var globalizationFiles = fs.readdirSync(gloablizationDir);
var coretests = [
'test/core/index.js',
'test/date/index.js',
'test/date_and_time/index.js',
'test/date_math/index.js',
'test/dst/index.js',
'test/parseExact/index.js',
'test/partial/index.js',
'test/relative/index.js',
'test/relative_date_and_time/index.js',
'test/time/index.js',
'test/tostring/index.js'
];
var extendedtests = [
'test/rememberthemilk/index.js',
'test/ruby_chronic/index.js',
'test/sugarpak/index.js',
];
gulp.task('coretest', function() {
return gulp.src(corefiles.concat(coretests))
.pipe(jasmine());
});
gulp.task('extendedtest', function() {
return gulp.src(corefiles.concat(extendedtests))
.pipe(jasmine());
});
gulp.task('buildCore', ['coretest'], function() {
return gulp.src(corefiles)
.pipe(sourcemaps.init())
.pipe(concat('date.js'))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build'))
});
gulp.task('buildGlobal', ['coretest'], function() {
var tasks = globalizationFiles.map(function(culture){
var files = [gloablizationDir + culture].concat(basefiles);
return pipeline(files, culture);
});
return merge(tasks);
});
function pipeline(files, culture) {
return gulp.src(files)
// .pipe(sourcemaps.init())
.pipe(concat(culture ? 'date-'+culture : 'date.js'))
// .pipe(uglify())
// .pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./build'))
}
gulp.task('test', function() {
runSequence(['coretest'],['extendedtest']);
});
gulp.task('default', ['buildCore','buildGlobal']);