forked from textAngular/textAngular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
142 lines (136 loc) · 4.29 KB
/
Gruntfile.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
module.exports = function (grunt) {
// load all grunt tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-istanbul-coverage');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-karma-coveralls');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-git');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('compile', ['concat', 'copy:setupFiles', 'jshint', 'uglify']);
grunt.registerTask('default', ['compile', 'test']);
grunt.registerTask('test', ['clean', 'jshint', 'karma', 'coverage']);
grunt.registerTask('travis-test', ['concat', 'copy:setupFiles', 'jshint', 'karma', 'coverage', 'coveralls']);
grunt.registerTask('release', ['bump-only','compile','changelog','gitcommit','bump-commit', 'shell:publish']);
grunt.registerTask('release:patch', ['bump-only:patch','compile','changelog','gitcommit','bump-commit', 'shell:publish']);
grunt.registerTask('release:minor', ['bump-only:minor','compile','changelog','gitcommit','bump-commit', 'shell:publish']);
grunt.registerTask('release:major', ['bump-only:major','compile','changelog','gitcommit','bump-commit', 'shell:publish']);
grunt.registerTask('release:prerelease', ['bump-only:prerelease','compile','changelog','gitcommit','bump-commit', 'shell:publish']);
var testConfig = function (configFile, customOptions) {
var options = { configFile: configFile, keepalive: true };
var travisOptions = process.env.TRAVIS && { browsers: ['PhantomJS'], reporters: ['dots','coverage'] };
return grunt.util._.extend(options, customOptions, travisOptions);
};
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
changelog: {options: {dest: 'changelog.md'}},
bump: {
options: {
files: ['package.json','bower.json'],
commitFiles: ['package.json', 'changelog.md','bower.json'],
pushTo: 'origin',
updateConfigs: ['pkg']
}
},
gitcommit: {
release: {
options: {
message: "chore(release): Build Dist files"
},
files: {
src: ['src/*','dist/*']
}
}
},
shell: {
publish: {
command: "npm publish"
}
},
clean: ["coverage"],
coverage: {
options: {
thresholds: {
'statements': 100,
'branches': 100,
'lines': 100,
'functions': 100
},
dir: 'coverage'
}
},
coveralls: {
options: {
debug: true,
coverage_dir: 'coverage',
force: true
}
},
karma: {
jquery: {
options: testConfig('karma-jquery.conf.js')
},
jqlite: {
options: testConfig('karma-jqlite.conf.js')
}
},
jshint: {
files: ['src/*.js', 'test/*.spec.js', 'test/taBind/*.spec.js', '!src/textAngular-sanitize.js'],// don't hint the textAngularSanitize as they will fail
options: {
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true,
globals: {}
}
},
copy: {
setupFiles: {
expand: true,
cwd: 'src/',
src: ['textAngularSetup.js', 'textAngular.css', 'textAngular-sanitize.js'],
dest: 'dist/'
}
},
concat: {
options: {
banner: "/*\n@license textAngular\nAuthor : Austin Anderson\nLicense : 2013 MIT\nVersion <%- pkg.version %>\n\nSee README.md or https://github.com/fraywing/textAngular/wiki for requirements and use.\n*/\n\n(function(){ // encapsulate all variables so they don't become global vars\n\"use strict\";",
footer: "})();"
},
dist: {
src: ['src/globals.js','src/factories.js','src/DOM.js','src/validators.js','src/taBind.js','src/main.js'],
dest: 'dist/textAngular.js'
}
},
uglify: {
options: {
mangle: true,
compress: {},
wrap: true,
preserveComments: 'some'
},
my_target: {
files: {
'dist/textAngular-rangy.min.js': ['bower_components/rangy/rangy-core.js', 'bower_components/rangy/rangy-selectionsaverestore.js'],
'dist/textAngular.min.js': ['dist/textAngularSetup.js','dist/textAngular.js'],
'dist/textAngular-sanitize.min.js': ['src/textAngular-sanitize.js']
}
}
},
watch: {
files: "lib/*.js",
tasks: "concat"
}
});
};