forked from Moscarda/OwnedTabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
123 lines (100 loc) · 3.64 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
(function () {
'use strict';
// Gulp dependencies
var args = require('yargs').argv,
gulp = require('gulp'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
jscs = require('gulp-jscs'),
jsonminify = require('gulp-jsonminify'),
Server = require('karma').Server;
// Linter
// ------------------------------------------------------------------------------------------------------
gulp.task('lint', function () {
return gulp
.src(['src/js/**/*.js', '!src/js/libs/*.js'])
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'))
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Core
// ------------------------------------------------------------------------------------------------------
gulp.task('build_core', ['build_background_and_content_scripts']);
gulp.task('build_background_and_content_scripts', function () {
return gulp
.src(['src/js/background.js', 'src/js/content.js'])
.pipe(gulp.dest('dist/js'));
});
// Options
// ------------------------------------------------------------------------------------------------------
gulp.task('build_options', ['build_options_styles', 'build_options_libs', 'build_options_script', 'build_options_html', 'build_options_icons']);
gulp.task('build_options_styles', function () {
return gulp
.src(['src/css/libs/**/*.css', 'src/css/options.css'])
.pipe(concat('options.css'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('build_options_libs', function () {
return gulp
.src(['src/js/libs/**/*.js'])
.pipe(concat('libs.js'))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/js/libs'));
});
gulp.task('build_options_script', function () {
return gulp
.src(['src/js/options/**/*.js'])
.pipe(concat('options.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build_options_icons', function () {
return gulp
.src(['src/js/options/icons.json'])
.pipe(jsonminify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build_options_html', function () {
return gulp
.src(['src/html/**/*.html'])
.pipe(gulp.dest('dist/html'));
});
// ------------------------------------------------------------------------------------------------------
// gulp tests --coverage=html
gulp.task('tests', function (done) {
var reporters = ['spec'],
coverage_reporter = { type: 'text', dir: 'coverage/' };
if (args.coverage) {
reporters.push('coverage');
if (typeof args.coverage === 'string') {
coverage_reporter.type = args.coverage;
}
}
new Server({
configFile: __dirname + '/karma.conf.js',
reporters: reporters,
coverageReporter: coverage_reporter
}, done).start();
});
gulp.task('build', [
'build_core',
'build_options',
'lint'
]);
gulp.task('watch', function () {
gulp.watch('src/**/*', ['build_core', 'build_options']);
});
// Default tasks (called when running `gulp` from cli)
gulp.task('default', [
'build_core',
'build_options',
'watch'
]);
}());