forked from ablanco/jquery.pwstrength.bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
106 lines (100 loc) · 3.02 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
/* eslint-env node */
var license =
'/*!\n' +
'* jQuery Password Strength plugin for Twitter Bootstrap\n' +
'* Version: <%= pkg.version %>\n' +
'*\n' +
'* Copyright (c) 2008-2013 Tane Piper\n' +
'* Copyright (c) 2013 Alejandro Blanco\n' +
'* Dual licensed under the MIT and GPL licenses.\n' +
'*/\n\n' +
'(function (jQuery) {\n',
eslintConfig = {
target: ['src/*js', 'spec/*js', 'Gruntfile.js']
},
jasmineConfig = {
options: {
forceExit: true,
jUnit: {
report: false
}
},
all: ['spec/']
},
concatConfig = {
options: {
banner: license,
footer: '}(jQuery));',
process: function(src, filepath) {
// Remove ALL block comments, the stripBanners only removes
// the first one
src = src.replace(/\/\*[\s\S]*?\*\//g, '');
return '// Source: ' + filepath + src;
}
},
dist: {
src: [
'src/i18n.js',
'src/rules.js',
'src/options.js',
'src/ui.js',
'src/ui.progressbar.js',
'src/ui.popover.js',
'src/methods.js'
],
dest: '<%= pkg.name %>.js'
}
},
uglifyConfig = {
options: {
banner:
'/* <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> - GPLv3 & MIT License */\n',
sourceMap: true,
sourceMapName: '<%= pkg.name %>.min.map'
},
dist: {
files: {
'<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
shellConfig = {
copyFile: {
command: 'cp <%= concat.dist.dest %> examples/pwstrength.js'
},
copyZxcvbn: {
command:
'cp bower_components/zxcvbn/dist/zxcvbn.js examples/zxcvbn.js'
},
copyI18next: {
command:
'cp bower_components/i18next/i18next.min.js examples/i18next.js'
},
makeDir: {
command: 'mkdir -p dist'
},
moveFiles: {
command: 'mv <%= pkg.name %>* dist/'
}
};
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
eslint: eslintConfig,
// eslint-disable-next-line camelcase
jasmine_node: jasmineConfig,
concat: concatConfig,
uglify: uglifyConfig,
shell: shellConfig
});
// Load the plugins
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.registerTask('test', ['eslint', 'jasmine_node']);
// Default task(s)
grunt.registerTask('default', ['eslint', 'concat', 'uglify', 'shell']);
};