forked from openedx-unsupported/edx-analytics-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
80 lines (71 loc) · 2.68 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
(function () {
'use strict';
var jshint = require('gulp-jshint'),
gulp = require('gulp'),
karma = require('karma').server,
path = require('path'),
browserSync = require('browser-sync'),
jscs = require('gulp-jscs'),
paths = {
spec: [
'analytics_dashboard/static/js/**/*.js',
'analytics_dashboard/static/js/test/**/*.js'
],
lint: [
'build.js',
'gulpfile.js',
'analytics_dashboard/static/js/**/*.js',
'analytics_dashboard/static/js/test/**/*.js'
],
templates: [
'analytics_dashboard/analytics_dashboard/templates/analytics_dashboard/*.html',
'analytics_dashboard/courses/templates/courses/*.html',
'analytics_dashboard/templates/*.html'
],
sass: ['analytics_dashboard/static/sass/*.scss'],
karamaConf: 'karma.conf.js'
};
// kicks up karma to the tests once
function runKarma(configFile, cb) {
karma.start({
configFile: path.resolve(configFile),
singleRun: true
}, cb);
}
gulp.task('lint', function () {
return gulp.src(paths.lint)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', function () {
return gulp.src(paths.lint)
.pipe(jscs());
});
// this task runs the tests. It doesn't give you very detailed results,
// so you may need to run the jasmine test page directly:
// http://127.0.0.1:8000/static/js/test/spec-runner.html
gulp.task('test', function (cb) {
runKarma(paths.karamaConf, cb);
});
// these are the default tasks when you run gulp
gulp.task('default', ['test', 'lint']);
// type 'gulp watch' to continuously run linting and tests
gulp.task('watch', function () {
gulp.watch(paths.spec, ['test', 'lint']);
});
// Proxy to django server (assuming that we're using port 8000 and
// localhost)
gulp.task('browser-sync', function () {
// there is a little delay before reloading b/c the sass files need to
// recompile, but we can't necessarily watch the generated directory
// because django creates a new css file that browser-sync doesn't
// know of and I can't figure out how to make it watch an entire
// directory
browserSync.init(null, {
proxy: 'localhost:9000',
files: paths.lint.concat(paths.templates).concat(paths.sass),
reloadDelay: 1000
});
});
}());