Completed
Push — master ( aaeace...6c8eb5 )
by Andres
35s
created

gulp.task(ꞌcopy-langꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 0
1
/* eslint-env node */
2
/*jslint node: true */
3
/*jslint esversion: 6 */
4
'use strict';
5
6
// Include gulp
7
let gulp = require('gulp');
8
let del = require('del');
9
let runSequence = require('run-sequence');
10
let uglifyes = require('uglify-es');
11
let composer = require('gulp-uglify/composer');
12
13
// Include plugins
14
let plugins = require('gulp-load-plugins')();
15
16
let Server = require('karma').Server;
17
let ugly = composer(uglifyes, console);
18
19
// unit test
20
gulp.task('karma', function (done) {
21
  new Server({
22
    configFile: __dirname + '/test/unit/karma.conf.js',
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
23
    singleRun: true
24
  }, done).start();
25
});
26
27
gulp.task('codecov', function() {
28
  return gulp
29
    .src(['test/unit/coverage/**/lcov.info'], { read: false })
30
    .pipe(plugins.codeclimateReporter({ token: '8e959350aa2fde657bbdd472964d5b2bdbb7d2ba10b8f6137865f2c241ecc86e' }))
31
  ;
32
});
33
34
// e2e test
35
gulp.task('connect', function() {
36
  return plugins.connect.server({
37
    root: 'build/',
38
    port: 9000
39
  });
40
});
41
42
gulp.task('webdriver_update', plugins.protractor.webdriver_update_specific({
43
	browsers: ['ignore_ssl']
44
}));
45
46
gulp.task('protractor', ['connect', 'webdriver_update'], function() {
47
  return gulp.src(['test/integration/spec/**.js'], { read: false })
48
    .pipe(plugins.protractor.protractor({
49
        configFile: 'test/integration/protractor.conf.js'
50
    }))
51
    .on('error', function(e) { throw e; });
52
  });
53
54
gulp.task('disconnect', function() {
55
  return plugins.connect.serverClose();
56
});
57
58
// clean
59
gulp.task('clean',function(){
60
  return del(['dist','build']);
61
});
62
63
// dist
64
65
gulp.task('htmlmin', function() {
66
  return gulp.src('build/**/*.html')
67
    .pipe(plugins.htmlmin({collapseWhitespace: true}))
68
    .pipe(gulp.dest('dist/'));
69
});
70
71
gulp.task('uglify', function() {
72
  return gulp.src('build/scripts/app.min.js')
73
    .pipe(ugly())
74
    .pipe(gulp.dest('dist/scripts'));
75
});
76
77
gulp.task('cleanCss', function() {
78
  return gulp.src('build/**/*.css')
79
    .pipe(plugins.cleanCss())
80
    .pipe(gulp.dest('dist/'));
81
});
82
83
gulp.task('minify', ['uglify', 'htmlmin', 'cleanCss']);
84
85
// FIXME can we do this with a parametric task?
86
gulp.task('copy-lib-dist', function() {
87
  return gulp.src('bower_components/**')
88
    .pipe(gulp.dest('dist/bower_components'));
89
});
90
91
// dependencies
92
93
gulp.task('bower', function() {
94
  return plugins.bower();
95
});
96
97
// copy
98
gulp.task('copy-js', function() {
99
  return gulp.src('src/scripts/**')
100
    .pipe(gulp.dest('build/scripts'));
101
});
102
103
gulp.task('copy-data', function() {
104
  return gulp.src('src/data/**')
105
    .pipe(gulp.dest('build/data'));
106
});
107
108
gulp.task('copy-lang', function() {
109
  return gulp.src('src/lang/**')
110
    .pipe(gulp.dest('build/lang'));
111
});
112
113
gulp.task('copy-html', function() {
114
  return gulp.src('src/html/**')
115
    .pipe(gulp.dest('build/'));
116
});
117
118
gulp.task('copy-css', function() {
119
  return gulp.src('src/styles/**')
120
    .pipe(gulp.dest('build/styles'));
121
});
122
123
gulp.task('copy-lib', function() {
124
  return gulp.src('bower_components/**')
125
    .pipe(gulp.dest('build/bower_components'));
126
});
127
128
gulp.task('copy-build', ['copy-js', 'copy-data', 'copy-lang', 'copy-html',
129
                        'copy-css', 'copy-lib']);
130
131
// build
132
133
gulp.task('populate_player', function() {
134
  return plugins.run('node build_scripts/populate_player.js',{silent:true}).exec();
135
});
136
137
gulp.task('populate_data', function() {
138
  return plugins.run('node build_scripts/populate_data.js',{silent:true}).exec();
139
});
140
141
gulp.task('generate_isotopes', function() {
142
  return plugins.run('node build_scripts/generate_isotopes.js',{silent:true}).exec();
143
});
144
145
gulp.task('generate_resource_matrix', function() {
146
  return plugins.run('node build_scripts/generate_resource_matrix.js',{silent:true}).exec();
147
});
148
149
gulp.task('generate_decay', function() {
150
  return plugins.run('node build_scripts/generate_decay.js',{silent:true}).exec();
151
});
152
153
gulp.task('generate_ions', function() {
154
  return plugins.run('node build_scripts/generate_ions.js',{silent:true}).exec();
155
});
156
157
gulp.task('generate_reactions', function() {
158
  return plugins.run('node build_scripts/generate_reactions.js',{silent:true}).exec();
159
});
160
161
gulp.task('generate_antimatter', function() {
162
  return plugins.run('node build_scripts/generate_antimatter.js',{silent:true}).exec();
163
});
164
165
gulp.task('generate_achievements', function() {
166
  return plugins.run('node build_scripts/generate_achievements.js',{silent:true}).exec();
167
});
168
169
gulp.task('generate_unlocks', function() {
170
  return plugins.run('node build_scripts/generate_unlocks.js',{silent:true}).exec();
171
});
172
173
gulp.task('generate_achievement_functions', function() {
174
  return plugins.run('node build_scripts/generate_achievement_functions.js',{silent:false}).exec();
175
});
176
177
gulp.task('generate_upgrades', function() {
178
  return plugins.run('node build_scripts/generate_upgrades.js',{silent:false}).exec();
179
});
180
181
gulp.task('generate_exotic_upgrades', function() {
182
  return plugins.run('node build_scripts/generate_exotic_upgrades.js',{silent:false}).exec();
183
});
184
185
gulp.task('generate_upgrade_functions', function() {
186
  return plugins.run('node build_scripts/generate_upgrade_functions.js',{silent:true}).exec();
187
});
188
189
gulp.task('generate_element_slot', function() {
190
  return plugins.run('node build_scripts/generate_element_slot.js',{silent:true}).exec();
191
});
192
193
gulp.task('check_isotopes', function() {
194
  return plugins.run('node build_scripts/check_isotopes.js',{silent:false}).exec();
195
});
196
197
gulp.task('sort_resources', function() {
198
  return plugins.run('node build_scripts/sort_resources.js',{silent:true}).exec();
199
});
200
201
gulp.task('process_lang', function() {
202
  return plugins.run('node build_scripts/process_lang.js',{silent:true}).exec();
203
});
204
205
gulp.task('concat', function() {
206
  return gulp.src(['build/scripts/modules/module.js',
207
    'build/scripts/**/*!(module.js)'])
208
    .pipe(plugins.concat('app.min.js'))
209
    .pipe(gulp.dest('build/scripts'));
210
});
211
212
// public tasks
213
gulp.task('build', function(callback) {
214
  runSequence(
215
    'clean',
216
    'bower',
217
    'copy-build',
218
    'generate_isotopes',
219
    'generate_resource_matrix',
220
    'generate_ions',
221
    'generate_decay',
222
    'generate_reactions',
223
    'generate_antimatter',
224
    'generate_achievements',
225
    'generate_unlocks',
226
    'generate_exotic_upgrades',
227
    'generate_upgrades',
228
    'generate_achievement_functions',
229
    'generate_upgrade_functions',
230
    'generate_element_slot',
231
    'process_lang',
232
    'sort_resources',
233
    'check_isotopes',
234
    'populate_player',
235
    'populate_data',
236
    'concat',
237
    callback);
238
});
239
240
gulp.task('build-unit-test', function(callback) {
241
  runSequence('build', 'karma', callback);
242
});
243
244
gulp.task('dist', function(callback) {
245
  runSequence('build', 'minify', 'copy-lib-dist', callback);
246
});
247
248
gulp.task('unit-test', function(callback) {
249
  runSequence('dist', 'karma', 'codecov', callback);
250
});
251
252
gulp.task('e2e-test', function(callback) {
253
  runSequence('dist', 'protractor', 'disconnect',
254
              callback);
255
});
256
257
gulp.task('test', ['unit-test', 'e2e-test']);
258