-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
136 lines (129 loc) · 4.18 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
/* eslint-env node */
module.exports = function(grunt) {
"use strict";
var SOURCE_FILES = [
"Gruntfile.js",
"src/**/*.js",
"test/*.js"
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
options: {},
build: ["test/*.tap", "test/coverage"]
},
concat: {
options: {
stripBanners: false,
seperator: ";"
},
dist: {
src: [
"src/utils.js",
"src/domainnamerule.js",
"src/saltthepass.js"
],
dest: "dist/<%= pkg.name %>.js"
},
"dist-withdeps": {
src: [
"bower_components/cryptojslib/components/core.js",
"bower_components/cryptojslib/components/x64-core.js",
"bower_components/cryptojslib/components/sha1.js",
"bower_components/cryptojslib/components/sha512.js",
"bower_components/cryptojslib/components/sha3.js",
"bower_components/cryptojslib/components/md5.js",
"bower_components/cryptojslib/components/ripemd160.js",
"bower_components/cryptojslib/components/enc-base64.js",
"src/utils.js",
"src/domainnamerule.js",
"src/saltthepass.js"
],
dest: "dist/<%= pkg.name %>.withdeps.js"
}
},
uglify: {
options: {
banner: "/*! <%= pkg.name %> v<%= pkg.version %> */\n",
mangle: true,
sourceMap: true
},
build: {
files: {
"dist/<%= pkg.name %>.min.js": ["dist/<%= pkg.name %>.js"],
"dist/<%= pkg.name %>.withdeps.min.js": ["dist/<%= pkg.name %>.withdeps.js"]
}
}
},
eslint: {
console: {
src: SOURCE_FILES
},
build: {
options: {
outputFile: "eslint.xml",
format: "jslint-xml",
silent: true
},
src: SOURCE_FILES
}
},
mochaTest: {
test: {
options: {
reporter: "tap",
captureFile: "test/mocha.tap"
},
src: [
"src/saltthepass.js",
"test/*.js"
]
}
},
karma: {
options: {
singleRun: true,
colors: true,
configFile: "./karma.config.js",
preprocessors: {
"dist/saltthepass.withdeps.js": ["coverage"]
},
basePath: "./",
files: [
"bower_components/mocha/mocha.css",
"bower_components/mocha/mocha.js",
"bower_components/expect/index.js",
"dist/saltthepass.withdeps.js",
"test/test-*.js"
]
},
console: {
browsers: ["PhantomJS"],
frameworks: ["mocha"]
}
}
});
//
// Plugins
//
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-karma");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("gruntify-eslint");
//
// Tasks
//
grunt.registerTask("test", ["mochaTest", "karma:console"]);
grunt.registerTask("lint", ["eslint:console"]);
grunt.registerTask("lint:build", ["eslint:build"]);
grunt.registerTask("build", ["concat", "uglify"]);
//
// Task Groups
//
grunt.registerTask("default", ["lint", "build"]);
grunt.registerTask("travis", ["clean", "lint", "build", "test"]);
grunt.registerTask("all", ["clean", "lint:console", "lint:build", "build", "test"]);
};