forked from rowlandekemezie/Document-Manager-REST-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·127 lines (120 loc) · 3.12 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·127 lines (120 loc) · 3.12 KB
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
var gulp = require('gulp'),
jade = require('jade'),
less = require('gulp-less'),
mocha = require('gulp-mocha'),
Server = require('karma').Server,
browserSync = require('browser-sync'),
stripeDebug = require('gulp-strip-debug'),
istanbul = require('gulp-istanbul'),
nodemon = require('gulp-nodemon'),
change = require('gulp-changed'),
rename = require('gulp-rename'),
del = require('del'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
notify = require('gulp-notify'),
usemin = require('gulp-usemin'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
stylish = require('jshint-stylish'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
minifyCss = require('gulp-minify-css'),
cache = require('gulp-cache'),
coveralls = require('gulp-coveralls'),
rev = require('rev');
// define jshint lint
gulp.task('jshint', function() {
return gulp.src('app/scripts/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
// define clean task
gulp.task('clean', function() {
return del(['dist/']);
});
// minify css
gulp.task('less', ['jshint'], function() {
return gulp.src('.../public/css/application.jade')
.pipe(less())
.pipe(minifyCss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dis/css'))
.pipe(notify({
message: 'less task completed'
}));
});
// task to minify css and js
gulp.task('usemin', function() {
return gulp.src()
})
// define task for imagemin
gulp.task('imagemin', function() {
return del(['dist/images']),
gulp.src('app/images/**/*')
.pipe(cache(imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/images'))
.pipe(notify({
message: 'Images task completed'
}));
});
// define coverage report
gulp.task('test-coverage', function() {
return gulp.src('./coverage/lcov/info')
.pipe(istanbul())
// .pipe(coveralls())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
// task for back end test
gulp.task('test:bend', function() {
return gulp.src('spec/*', {
read: false
})
.pipe(mocha({
reporter: 'spec'
}))
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 80%
.pipe(istanbul.enforceThresholds({
thresholds: {
global: 80
}
}));
});
// task for front end test
gulp.task('test:fend', function(done) {
new Server({
configFile: __dirname + '/karma.conf.js',
}, done).start();
});
// task to watch files
gulp.task('watch', function() {
gulp.watch();
gulp.watch();
})
// task for nodemon
gulp.task('nodemon', function() {
nodemon({
ext: 'jade js css',
script: '',
})
.on('watch', ['watch'])
.on('start', ['watch'])
.on('restart', function() {
console.log('Restarted..');
});
});
// register default tasks
gulp.task('default', ['clean'], function() {
gulp.start('usemin', 'imagemin', 'nodemon', 'build');
});
// register test task
gulp.task('test', ['test:fend', 'test:bend', 'test-coverage',])