forked from ngx-material-keyboard/angular-material-keyboard
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·118 lines (105 loc) · 3.67 KB
/
gulpfile.js
File metadata and controls
executable file
·118 lines (105 loc) · 3.67 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
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('./package.json');
var header = [
'/**',
' * <%= pkg.name %>',
' * <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @author <%= pkg.author %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' *',
' * NOTE: This project was originally forked from https://github.com/davidenke/angular-material-keyboard.',
' * Additional changes have been made since the last official release on the original repo. ',
' * The changelog below is from the original repo and does not reflect the changes ',
' * that have been made since then.',
' */',
''
].join('\n');
patchPackageJSON();
build();
function patchPackageJSON () {
var authors = [];
for (var maintainerIndex in pkg.maintainers) {
if (!pkg.maintainers.hasOwnProperty(maintainerIndex)) {
continue;
}
var author = pkg.maintainers[maintainerIndex];
authors.push(author.name + ' <' + author.email + '>')
}
pkg.author = authors.join('; ')
}
function build () {
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/mdKeyboardUtil.service.js',
'src/js/mdKeyboard.service.js',
'src/js/mdKeyboard.directive.js'
])
.pipe(plugins.concat('mdKeyboard.js'))
.pipe(plugins.header(header, {pkg: pkg}))
.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.cleanCss())
.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('./package.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);
});
});