forked from CoderDojo/cp-zen-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (75 loc) · 2.28 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
81
82
83
84
85
var path = require('path'),
gulp = require('gulp'),
concat = require('gulp-concat'),
ngAnnotate = require('gulp-ng-annotate'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
semistandard = require('gulp-semistandard'),
KarmaServer = require('karma').Server;
dependencies = require('./web/public/dependencies.json'),
app = require('./web/public/app.json'),
less = require('gulp-less')
del = require('del');
function relativePath(paths) {
if (paths.constructor === [].constructor) {
for (var i = 0; i < paths.length; i++) {
paths[i] = path.join(__dirname, paths[i]);
}
return paths;
} else {
return path.join(__dirname, paths);
}
}
gulp.task('clean', function () {
return del(relativePath([
'./web/public/dist/**/*'
]));
});
gulp.task('jshint', function () {
return gulp.src(relativePath([
'./web/controllers/**/*.js',
'./lib/**/*.js',
'./web/models/!**!/!*.js',
'./web/public/js/**/*.js'
]))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('semistandard', function () {
return gulp.src(relativePath([
'./lib/**/*.js'
]))
.pipe(semistandard())
.pipe(semistandard.reporter('default', {
breakOnError: true
}));
});
gulp.task('build-dependencies', ['clean'], function () {
return gulp.src(relativePath(dependencies))
.pipe(ngAnnotate())
.pipe(concat('dependencies.js'))
.pipe(uglify())
.pipe(gulp.dest(relativePath('./web/public/dist/')));
});
gulp.task('build-less', ['clean'], function () {
return gulp.src(relativePath('./web/public/css/app.less'))
.pipe(less({
compress: true
}))
.pipe(gulp.dest(relativePath('./web/public/dist/css/')))
});
gulp.task('build', ['clean', 'jshint', 'build-less', 'build-dependencies'], function () {
return gulp.src(relativePath(app))
.pipe(ngAnnotate())
.pipe(concat('app.js'))
//.pipe(uglify()) // Commented out until we figure it out why it's breaking
.pipe(gulp.dest(relativePath('./web/public/dist/')));
});
gulp.task('test', ['semistandard', 'build'], function (done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('default', ['test']);