forked from nagyist/TourneyMan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
151 lines (130 loc) · 3.17 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
const gulp = require("gulp");
const del = require('del');
const sourcemaps = require("gulp-sourcemaps");
const babel = require("gulp-babel");
const less = require('gulp-less');
const concat = require("gulp-concat");
//var uglify = require("gulp-uglify");
const runSequence = require('run-sequence');
const spawn = require('child_process').spawn;
const Mocha = require('mocha');
const through = require('through2');
const webpack = require('webpack-stream');
gulp.task('electron', function(done) {
// Start browser process
var electron = spawn('electron', ['build']);
done();
});
let appFiles = [
'src/app/index.html',
'src/app/templates/*.html',
'src/app/css/*.less',
'src/app/css/*.css',
'src/app/**/*.js',
'spec/*.js',
];
/*gulp.task("vendorjs", function() {
return gulp.src('src/vendor.js')
.pipe(webpack())
.pipe(gulp.dest('build/vendor.js'));
});*/
gulp.task("js", function () {
return gulp.src('src/app/app.js')
.pipe(webpack({
target: 'web',
devtool: 'source-map',
output: {
filename: 'app.js',
},
}
))
.pipe(gulp.dest('build'));
});
gulp.task("html", function() {
return gulp.src([
"src/app/index.html",
"src/app/templates/**/*.html",
]).pipe(concat("index.html"))
.pipe(gulp.dest("build"))
});
gulp.task("vendorcss", function() {
return gulp.src([
"src/vendor/css/*.css",
])
.pipe(concat("vendor.css"))
.pipe(gulp.dest("build"))
});
gulp.task("vendorfonts", function() {
return gulp.src([
"src/vendor/fonts/*",
]).pipe(gulp.dest("build/fonts"))
});
gulp.task("styles", function() {
return gulp.src([
"src/app/css/*.less"
])
.pipe(less())
.pipe(concat("app.css"))
.pipe(gulp.dest("build"))
});
gulp.task('copy_files', function() {
return gulp.src([
"src/app/templates/index.html",
"src/app/main.js",
"src/app/assets/**/*",
"src/app/package.json",
"icon.icns"
])
.pipe(gulp.dest("build"))
});
gulp.task('copy_package_files', function() {
return gulp.src([
"icon.ico",
"icon.icns",
"background.png"
])
.pipe(gulp.dest("build/build"))
});
gulp.task('prep_fixtures', function() {
return gulp.src([
"src/app/templates/*.html",
])
.pipe(gulp.dest("build/spec/fixtures"));
});
gulp.task('test', function() {
require('babel-core/register');
let mocha = new Mocha({
reporter: 'nyan'
});
let unhandledRejectionExitCode = 0;
process.on("unhandledRejection", (reason, promise) => {
unhandledRejectionExitCode = 1;
throw reason;
});
process.prependListener("exit", (code) => {
if (code === 0) {
process.exit(unhandledRejectionExitCode);
}
});
return gulp
.src([
'spec/**/*_spec.js'
],{read: false})
.pipe(through.obj((file, encoding, callback) => {
callback(null, mocha.addFile(file.path));
})).on('finish', () => {
return mocha.run();
});
});
gulp.task('clean', function() {
return del([
'build',
]);
});
gulp.task('build', function(done) {
runSequence(['js', "html", 'vendorcss', "vendorfonts", 'styles', 'copy_files'], done);
});
gulp.task('default', function(done) {
runSequence('clean', 'build', 'electron', done);
});