Completed
Push — master ( bfee8a...41eb99 )
by Andres
28s
created

gulp.task(ꞌcheck_isotopesꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 3
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-html', function() {
109
  return gulp.src('src/html/**')
110
    .pipe(gulp.dest('build/'));
111
});
112
113
gulp.task('copy-css', function() {
114
  return gulp.src('src/styles/**')
115
    .pipe(gulp.dest('build/styles'));
116
});
117
118
gulp.task('copy-lib', function() {
119
  return gulp.src('bower_components/**')
120
    .pipe(gulp.dest('build/bower_components'));
121
});
122
123
gulp.task('copy-build', ['copy-js', 'copy-data', 'copy-html',
124
                        'copy-css', 'copy-lib']);
125
126
// build
127
128
gulp.task('populate_player', function() {
129
  return plugins.run('node build_scripts/populate_player.js',{silent:true}).exec();
130
});
131
132
gulp.task('populate_data', function() {
133
  return plugins.run('node build_scripts/populate_data.js',{silent:true}).exec();
134
});
135
136
gulp.task('generate_isotopes', function() {
137
  return plugins.run('node build_scripts/generate_isotopes.js',{silent:true}).exec();
138
});
139
140
gulp.task('generate_resource_matrix', function() {
141
  return plugins.run('node build_scripts/generate_resource_matrix.js',{silent:true}).exec();
142
});
143
144
gulp.task('generate_decay', function() {
145
  return plugins.run('node build_scripts/generate_decay.js',{silent:true}).exec();
146
});
147
148
gulp.task('generate_ions', function() {
149
  return plugins.run('node build_scripts/generate_ions.js',{silent:true}).exec();
150
});
151
152
gulp.task('generate_reactions', function() {
153
  return plugins.run('node build_scripts/generate_reactions.js',{silent:true}).exec();
154
});
155
156
gulp.task('generate_antimatter', function() {
157
  return plugins.run('node build_scripts/generate_antimatter.js',{silent:true}).exec();
158
});
159
160
gulp.task('generate_achievements', function() {
161
  return plugins.run('node build_scripts/generate_achievements.js',{silent:true}).exec();
162
});
163
164
gulp.task('generate_unlocks', function() {
165
  return plugins.run('node build_scripts/generate_unlocks.js',{silent:true}).exec();
166
});
167
168
gulp.task('generate_achievement_functions', function() {
169
  return plugins.run('node build_scripts/generate_achievement_functions.js',{silent:false}).exec();
170
});
171
172
gulp.task('generate_upgrades', function() {
173
  return plugins.run('node build_scripts/generate_upgrades.js',{silent:false}).exec();
174
});
175
176
gulp.task('generate_exotic_upgrades', function() {
177
  return plugins.run('node build_scripts/generate_exotic_upgrades.js',{silent:false}).exec();
178
});
179
180
gulp.task('generate_upgrade_functions', function() {
181
  return plugins.run('node build_scripts/generate_upgrade_functions.js',{silent:true}).exec();
182
});
183
184
gulp.task('generate_element_slot', function() {
185
  return plugins.run('node build_scripts/generate_element_slot.js',{silent:true}).exec();
186
});
187
188
gulp.task('check_isotopes', function() {
189
  return plugins.run('node build_scripts/check_isotopes.js',{silent:false}).exec();
190
});
191
192
gulp.task('sort_resources', function() {
193
  return plugins.run('node build_scripts/sort_resources.js',{silent:true}).exec();
194
});
195
196
gulp.task('concat', function() {
197
  return gulp.src(['build/scripts/modules/module.js',
198
    'build/scripts/**/*!(module.js)'])
199
    .pipe(plugins.concat('app.min.js'))
200
    .pipe(gulp.dest('build/scripts'));
201
});
202
203
// public tasks
204
gulp.task('build', function(callback) {
205
  runSequence(
206
    'clean',
207
    'bower',
208
    'copy-build',
209
    'generate_isotopes',
210
    'generate_resource_matrix',
211
    'generate_ions',
212
    'generate_decay',
213
    'generate_reactions',
214
    'generate_antimatter',
215
    'generate_achievements',
216
    'generate_unlocks',
217
    'generate_exotic_upgrades',
218
    'generate_upgrades',
219
    'generate_achievement_functions',
220
    'generate_upgrade_functions',
221
    'generate_element_slot',
222
    'sort_resources',
223
    'check_isotopes',
224
    'populate_player',
225
    'populate_data',
226
    'concat',
227
    callback);
228
});
229
230
gulp.task('build-unit-test', function(callback) {
231
  runSequence('build', 'karma', callback);
232
});
233
234
gulp.task('dist', function(callback) {
235
  runSequence('build', 'minify', 'copy-lib-dist', callback);
236
});
237
238
gulp.task('unit-test', function(callback) {
239
  runSequence('dist', 'karma', 'codecov', callback);
240
});
241
242
gulp.task('e2e-test', function(callback) {
243
  runSequence('dist', 'protractor', 'disconnect',
244
              callback);
245
});
246
247
gulp.task('test', ['unit-test', 'e2e-test']);
248