-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
117 lines (103 loc) · 2.7 KB
/
gulpfile.js
File metadata and controls
117 lines (103 loc) · 2.7 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
var gulp = require('gulp');
var connect = require('gulp-connect');
var rename_ = require('gulp-rename');
var bump = require('gulp-bump');
var gulp = require('gulp');
var karma = require('karma').server;
var xingTraceurTask = require('xing-traceur').rawTask;
var htmlToJs = require('gulp-html-to-js');
var extReplace = require('gulp-ext-replace');
var TRACEUR_OPTIONS = require('./config').traceur;
var PATH = {
DIST: './dist/',
BUILD: './build/',
SRC: './src/**/*.js',
TEST: './test/**/*.js',
TPL: "src/**/*.tpl.html"
};
gulp.task('template', function() {
gulp.src(PATH.TPL)
.pipe(htmlToJs())
.pipe(extReplace('.tpl', '.tpl.html'))
.pipe(gulp.dest('src'));
});
gulp.task('testPrep', ['template'], function(done) {
var files = [{
dest: PATH.BUILD + "test-main.js",
src: [PATH.TEST]
}]
var options = {
sourceMaps: true,
traceurOptions: TRACEUR_OPTIONS,
moduleMaps: require('./moduleMaps')
}
xingTraceurTask(options, files, function(result) {
done(!result);
});
});
/**
* Run test once and exit
*/
gulp.task('test', ['testPrep'], function (done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
/**
* Run test once and exit, firefox browser
*/
gulp.task('test:firefox', ['testPrep'], function (done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
browsers: ["Firefox"],
singleRun: true
}, done);
});
/**
* Watch for file changes and re-run tests on each change
*/
gulp.task('tdd', ['testPrep'], function (done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
}, done);
gulp.watch(PATH.TEST, ['testPrep']);
gulp.watch(PATH.SRC, ['testPrep']);
});
// A wrapper around gulp-rename to support `dirnamePrefix`.
function rename(obj) {
return rename_(function(parsedPath) {
return {
extname: obj.extname || parsedPath.extname,
dirname: (obj.dirnamePrefix || '') + parsedPath.dirname,
basename: parsedPath.basename
};
});
}
gulp.task('dist', function() {
gulp.src(PATH.SRC, {base: './src'})
.pipe(rename({extname: '.js', dirnamePrefix: PATH.DIST}))
.pipe(gulp.dest('.'));
});
// Basic usage:
// Will patch the version
gulp.task('bump:patch', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
});
// Defined method of updating:
// Semantic
gulp.task('bump:minor', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'minor'}))
.pipe(gulp.dest('./'));
});
// Defined method of updating:
// Semantic major
gulp.task('bump:major', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'major'}))
.pipe(gulp.dest('./'));
});
gulp.task('default', ['tdd']);