-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
162 lines (140 loc) · 3.8 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
152
153
154
155
156
157
158
159
160
/** Regular npm dependendencies */
var gulp = require('gulp');
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var gulpExec = require('gulp-exec');
var wiredep = require('wiredep').stream;
var runSequence = require('run-sequence');
var del = require('del');
var stylish = require('jshint-stylish');
var rimraf = require('rimraf');
var ncp = require('ncp');
var path = require('path');
var mkdirp = require('mkdirp');
/** Gulp dependencies */
var gutil = require('gulp-util');
var inject = require('gulp-inject');
var less = require('gulp-less');
var jshint = require('gulp-jshint');
var runElectron = require("gulp-run-electron");
var nachosBuild = require("gulp-nachos-build");
/** Grab-bag of build configuration. */
var config = {};
/** Gulp tasks */
gulp.task('default', ['test']);
gulp.task('test', ['jshint']);
gulp.task('jshint', function () {
gulp.src(['./client/**/*.js', '!./client/bower_components/**/*.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('serve', function (cb) {
runSequence(
'build',
'electron',
cb);
});
gulp.task('serve:dist', function (cb) {
runSequence(
'build',
cb);
});
gulp.task('build', function (cb) {
runSequence(
'clean:tmp',
'less',
'inject:css',
'inject:js',
'wiredep',
cb);
});
gulp.task('build:dist', function (cb) {
runSequence(
'lint',
'build',
'electron:build',
cb);
});
gulp.task('electron:build', function (cb) {
nachosBuild(cb);
});
gulp.task('wiredep', function () {
gulp.src('client/index.html')
.pipe(wiredep({
ignorePath: 'client/'
}))
.pipe(gulp.dest('client'));
});
gulp.task('less', ['inject:less'], function () {
return gulp.src([
'client/app/app.less'
])
.pipe(less({
paths: [
'client/bower_components',
'client/app',
'client/components'
]
}))
.pipe(gulp.dest('.tmp/app'));
});
gulp.task('inject:less', function () {
return gulp.src('client/app/app.less')
.pipe(inject(gulp.src([
'client/{app,components}/**/*.less',
'!client/app/app.less'
], {read: false}), {
transform: function (filePath) {
filePath = filePath.replace('/client/app/', '');
filePath = filePath.replace('/client/components/', '');
return '@import \'' + filePath + '\';';
},
starttag: '// injector',
endtag: '// endinjector'
}))
.pipe(gulp.dest('client/app'));
});
gulp.task('inject:css', function () {
return gulp.src('client/index.html')
.pipe(inject(gulp.src([
'client/{app,components}/**/*.css'
], {read: false}), {
transform: function (filePath) {
filePath = filePath.replace('/client/', '');
filePath = filePath.replace('/.tmp/', '');
return '<link rel="stylesheet" href="' + filePath + '">';
},
starttag: '<!-- injector:css -->',
endtag: '<!-- endinjector -->'
}))
.pipe(gulp.dest('client'));
});
gulp.task('inject:js', function () {
return gulp.src('client/index.html')
.pipe(inject(gulp.src([
'client/{app,components}/**/*.js',
'!client/app/app.js',
'!client/{app,components}/**/*.spec.js',
'!client/{app,components}/**/*.mock.js'
], {read: false}), {
transform: function (filePath) {
filePath = filePath.replace('/client/', '');
return '<script src="' + filePath + '"></script>';
},
starttag: '<!-- injector:js -->',
endtag: '<!-- endinjector -->'
}))
.pipe(gulp.dest('client'));
});
gulp.task('clean', ['clean:tmp', 'clean:dist']);
gulp.task('clean:tmp', function (cb) {
del(['.tmp'], cb);
});
gulp.task('clean:dist', function (cb) {
del(['dist'], cb);
});
gulp.task('electron', function () {
return gulp.src('.')
.pipe(runElectron());
});