-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
157 lines (139 loc) · 3.97 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks needed for this run
require('jit-grunt')(grunt);
// configurable paths
var config = {
app: 'src',
testJs: '<%= config.test %>/js',
test: 'test',
dist: 'build'
};
grunt.registerMultiTask('echo', 'Echo back input', function(){
var data = this.data;
if (typeof (data) === 'string') {
if (grunt.file.exists(data)) {
grunt.log.writeln(grunt.file.read(data));
} else {
grunt.log.writeln(data);
}
}
if (typeof (data) === 'object') {
var key;
for (key in data) {
if (data.hasOwnProperty(key)) {
grunt.log.writeln(data[key]);
}
}
}
});
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
config: config,
banner: '/*\n * <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %>\n *\n * Copyright (C) 2012 Peter Eigenschink (http://www.peter-eigenschink.at/)\n * Dual-licensed under MIT and Beerware license.\n*/\n',
echo: {
help: 'README.md'
},
clean: {
options: {
force: true
},
links: ["<%= config.dist %>/**", "coverage/**"]
},
jsdoc : {
dist : {
src: ['<%= config.app %>/*.js', '<%= config.app %>/**/*.js'],
options: {
destination: 'docs/jsdoc'
}
}
},
concat: {
options: {
banner: '<%= banner %>;(function (name, context, factory) {\n\n // Supports UMD. AMD, CommonJS/Node.js and browser context\n if (typeof module !== "undefined" && module.exports) {\n module.exports = factory();\n } else if (typeof define === "function" && define.amd) {\n define(factory);\n } else {\n context[name] = factory();\n }\n\n})("steg", this, function () {\nvar Cover = function Cover() {};\n',
footer: '\nreturn new Cover();\n});'
},
dist: {
src: ['<%= config.app %>/util.js','<%= config.app %>/config.js','<%= config.app %>/capacity.js','<%= config.app %>/encode.js','<%= config.app %>/decode.js'],
dest: '<%= config.testJs %>/steganography.js',
nonull: true
}
},
copy: {
dist: {
src: '<%= config.testJs %>/steganography.js',
dest: '<%= config.dist %>/steganography.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
build: {
src: '<%= config.dist %>/steganography.js',
dest: '<%= config.dist %>/steganography.min.js'
}
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= config.testJs %>/{,*/}*.js'
]
},
karma: {
options: {
configFile: '<%= config.test %>/karma.conf.js',
},
unit: {
singleRun: true,
browsers: ['Chrome'],
reporters: ['dots', 'coverage']
},
watch: {
browsers: ['Chrome'],
reporters: ['dots', 'coverage']
},
debug: {
reporters: ['progress']
}
},
checkDependencies: {
'this': {
options: {
npmInstall: true
}
}
}
});
// Print help
grunt.registerTask('help', ['echo:help']);
// Verify installation
grunt.registerTask('verify', ['checkDependencies']);
grunt.registerTask('test', ['karma:unit']);
// Build
grunt.registerTask('build', function(target) {
target = target ? ':'+target : '';
grunt.task.run([
'clean',
'concat' + target,
'jshint',
'test',
'copy:dist',
'uglify',
'jsdoc'
]);
});
// Setup default task that runs when you just run 'grunt'
grunt.registerTask('default', ['build']);
};