-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
executable file
·102 lines (90 loc) · 2.86 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
var gulp = require('gulp'),
path = require('path'),
jshintReporter = require('jshint-stylish'),
plugins = require('gulp-load-plugins')({
config: path.join(__dirname, 'package.json'),
rename: {
'gulp-angular-embed-templates': 'embedTemplates'
}
});
var sctiptPath = {
src: {
files: 'src/js/**/*.js'
}
};
gulp.task('jshint', function (done) {
gulp
.src(sctiptPath.src.files)
.pipe(plugins.jshint('.jshintrc'))
.pipe(plugins.jshint.reporter(jshintReporter));
done();
});
gulp.task('build', function () {
var pkg = require('./bower.json');
var header = ['/**',
' * <%= pkg.name %>',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @author <%= pkg.author %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
'(function (angular) {',
'',
''].join('\n');
var footer = [
'',
'})(angular);',
''].join('\n');
gulp
.src([
'src/js/mdKeyboard.module.js',
'src/js/mdKeyboard.config.icons.js',
'src/js/mdKeyboard.config.layouts.js',
'src/js/mdKeyboard.config.deadkey.js',
'src/js/mdKeyboard.config.numpad.js',
'src/js/mdKeyboard.config.symbols.js',
'src/js/mdKeyboard.decorator.js',
'src/js/mdKeyboard.provider.js',
'src/js/mdKeyboard.directive.js'
])
.pipe(plugins.concat('mdKeyboard.js'))
.pipe(plugins.header(header, {pkg: pkg}))
.pipe(plugins.footer(footer))
.pipe(plugins.embedTemplates())
.pipe(plugins.replace(/[\r\n]+\s*\/\/.*TODO:+.*/gi, ''))
.pipe(plugins.ngAnnotate())
.pipe(gulp.dest('./dist/'))
.pipe(plugins.uglify({mangle: false}))
.pipe(plugins.concat('mdKeyboard.min.js'))
.pipe(gulp.dest('./dist/'));
gulp
.src('src/css/*.scss')
.pipe(plugins.sass().on('error', plugins.sass.logError))
.pipe(gulp.dest('./dist/'))
.pipe(plugins.concat('mdKeyboard.min.css'))
.pipe(plugins.sourcemaps.init())
.pipe(plugins.cleanCss())
.pipe(plugins.sourcemaps.write())
.pipe(gulp.dest('./dist/'));
});
gulp.task('default', ['jshint', 'build'], function () {
gulp.watch(sctiptPath.src.files, ['jshint', 'build']);
});
gulp.task('changelog', function (done) {
var pkg = require('./bower.json');
var changelog = require('conventional-changelog');
var fs = require('fs');
var options = {
repository: pkg.homepage,
version: pkg.version,
file: 'CHANGELOG.md'
};
var filePath = './' + options.file;
changelog(options, function (err, log) {
if (err) {
throw err;
}
fs.writeFile(filePath, log, done);
});
});