Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
85 lines (74 loc) · 2.27 KB
/
Copy pathgulpfile.js
File metadata and controls
85 lines (74 loc) · 2.27 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
'use strict';
var pkg = require('./package.json'),
gulp = require('gulp'),
concat = require('gulp-concat-util'),
gutil = require('gulp-util'),
path = require('path'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
del = require('del'),
ngtemplate = require('gulp-ngtemplate'),
ngAnnotate = require('gulp-ng-annotate'),
htmlmin = require('gulp-htmlmin'),
Server = require('karma').Server;
var paths = {
src: 'src',
dist: 'dist',
scripts: '**/*.js',
extName: 'ng-hateoas-helper'
};
var banner = gutil.template('/**\n' +
' * <%= pkg.name %>\n' +
' * @version v<%= pkg.version %> - <%= today %>\n' +
' */\n', {
file: '',
pkg: pkg,
today: new Date().toISOString().substr(0, 10)
});
var exclude = ['angular'];
// CLEAN
gulp.task('clean', function() {
del.sync([paths.dist]);
});
//Test
gulp.task('test', function() {
var server = new Server({
configFile: path.join(process.cwd(), '/test/karma.conf.js'),
browsers: ['PhantomJS'],
singleRun: true
});
server.start();
});
gulp.task('tdd', function(done) {
new Server({
configFile: path.join(process.cwd(), '/test/karma.conf.js'),
browsers: ['Chrome', 'Firefox', 'PhantomJS'],
singleRun: false
}, done).start();
});
//SCRIPTS
gulp.task('buildScripts', ['clean'], function() {
return gulp.src(['module.js', paths.scripts], {
cwd: paths.src
})
.pipe(ngAnnotate())
.pipe(concat(pkg.name + '.js', {
process: function(src) {
return '// Source: ' + path.basename(this.path) + '\n' + (src.trim() + '\n').replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
}))
.pipe(concat.header('(function(window, document, undefined) {\n\'use strict\';\n'))
.pipe(concat.footer('\n})(window, document);\n'))
.pipe(concat.header(banner))
.pipe(gulp.dest(paths.dist))
.pipe(rename(function(path) {
path.extname = '.min.js'
}))
.pipe(uglify())
.pipe(concat.header(banner))
.pipe(gulp.dest(paths.dist));
});
//Default
gulp.task('build', ['buildScripts']);
gulp.task('dist', ['test', 'build']);
gulp.task('default', ['dist']);