-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
78 lines (70 loc) · 1.89 KB
/
Copy pathgulpfile.js
File metadata and controls
78 lines (70 loc) · 1.89 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
var args = require('yargs').argv;
var fs = require('fs');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({
lazy: true
});
var input = {
'javascript': [
'src/**/*.module.js',
'src/**/*.js'
]
},
output = {
'dest': 'dist/',
'file': 'mc-google-place.js',
'min': 'mc-google-place.min.js'
};
/* run the watch task when gulp is called without arguments */
gulp.task('default', ['build-js']);
/**
* vet the code and create coverage report
* @return {Stream}
*/
gulp.task('vet', function() {
log('Analyzing source with JSHint and JSCS');
return gulp
.src(input.javascript)
.pipe($.if(args.verbose, $.print()))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', {
verbose: true
}))
.pipe($.jshint.reporter('fail'))
.pipe($.jscs());
});
/* concat javascript files */
gulp.task('concat', ['vet'], function() {
return gulp.src(input.javascript)
.pipe($.sourcemaps.init())
.pipe($.concat(output.file))
.pipe($.sourcemaps.write())
.pipe($.header(getCopyright()))
.pipe(gulp.dest(output.dest));
});
/* minify */
gulp.task('uglify', ['concat'], function() {
return gulp.src(output.dest + output.file)
.pipe($.uglify())
.pipe($.rename(output.min))
.pipe(gulp.dest(output.dest));
});
/**
* Log a message or series of messages using chalk's blue color.
* Can pass in a string, object or array.
*/
function log(msg) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
} else {
$.util.log($.util.colors.blue(msg));
}
}
// Get copyright using NodeJs file system
function getCopyright() {
return fs.readFileSync('Copyright');
};