-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (82 loc) · 2.27 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
86
87
88
/**
* gulpfile for radiatus
*
* Here are the common tasks used:
* build
* - Lint and compile
* - (default Grunt task)
* test
* - Run all tests
* jsdoc
* - Generate jsdoc documentation
**/
var gulp = require("gulp");
var jshint = require("gulp-jshint");
var jsdoc = require("gulp-jsdoc");
var mocha = require("gulp-mocha");
var through = require("through");
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var fs = require("fs-extra");
var path = require("path");
gulp.task("copy_client_lib", function() {
"use strict";
var copyToDist = function(filepath) {
fs.copy(
filepath,
"./public/dist/" + path.basename(filepath),
function(err) { if (err) { throw err; } }
);
};
copyToDist("./bower_components/foundation/css/foundation.css");
copyToDist("./bower_components/cookies-js/dist/cookies.min.js");
copyToDist("./bower_components/es6-promise-polyfill/promise.js");
});
gulp.task("build_freedom_stub", function() {
"use strict";
var entry = "./src/client/freedom.js";
var filename = path.basename(entry);
var bundler = browserify({
entries: [ entry ],
debug: true
});
var bundle = function() {
return bundler
.bundle()
.pipe(source(filename))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
// Add transformation tasks to the pipeline here.
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./public/dist/'));
};
return bundle();
});
gulp.task("generate_jsdoc", function() {
"use strict";
return gulp.src("./src/**/*.js")
.pipe(jsdoc("./build/doc"));
});
gulp.task("lint", function() {
"use strict";
return gulp.src([
"*.js",
"*.json",
"config/**/*",
"src/**/*.js"
]).pipe(jshint({ lookup: true }))
.pipe(jshint.reporter("default"));
});
gulp.task("mocha_test", function() {
"use strict";
return gulp.src("./src/**/*.spec.js")
.pipe(mocha({ reporter: "spec" }));
});
gulp.task("build", [ "copy_client_lib", "build_freedom_stub" ]);
gulp.task("test", [ "lint", "mocha_test" ]);
gulp.task("jsdoc", [ "generate_jsdoc" ]);
gulp.task("default", [ "build", "test" ]);