forked from metacert/cryptonite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
150 lines (137 loc) 路 4.11 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
module.exports = function(grunt) {
grunt.initConfig({
jsdoc : {
dist : {
src: ['src/**/*.js'],
options: {
destination: 'output/doc',
template: "node_modules/ink-docstrap/template",
configure: "node_modules/ink-docstrap/template/jsdoc.conf.json"
}
}
},
jslint: { // configure the task
// lint your project's client code
client: {
src: [
'src/js/**/*.js'
],
exclude: [
'src/js/lib/*.*'
],
directives: {
predef: [
'module',
'require',
'jQuery',
'$',
'self',
'chrome',
'MetaCertApi',
'Background',
'ConfigSettings',
'Cryptonite',
'Options',
'Popup',
'CryptoniteUtils',
'PropertyDAO'
],
"bitwise": false,
"browser": true,
"eval": false,
"evil": false,
"getset": true,
"long": true,
"maxerr": 5000,
"multivar": false,
"nomen": true,
"passfail": false,
"plusplus": true,
"regexp": true,
"single": true,
"sloppy": true,
"todo": true,
"this": true,
"undef": false,
"vars": true,
"white": true
},
options: {
errorsOnly: false,
failOnError: false,
log: 'output/grunt-jslint-results.log'
}
}
},
exec: {
jslint: {
cmd: function(outputToConsole) {
var resultsFile = 'output/jslint-results.log';
var filesToExamine = 'src/js/background/api/metacertApi.js src/js/background/background.js src/js/background/configSettings.js src/js/contentScript/cryptonite.js src/js/options/options.js src/js/popup/popup.js src/js/utils/cryptoniteUtils.js src/js/utils/propertyDAO.js';
var outputCommand = '';
if (outputToConsole) {
outputCommand = ' --color true';
} else {
outputCommand = ' > ' + resultsFile;
}
var commandToExecute = [
'rm -rfd ' + resultsFile,
'jslint ' + filesToExamine + outputCommand
].join('&&');
return commandToExecute;
},
exitCode: [0,1]
}
},
strip_code: {
options: {
parityCheck: true,
intersectionCheck: true,
blocks: [
{
start_block: '/* start-cryptonite-private-code */',
end_block: '/* end-cryptonite-private-code */',
},
{
start_block: '<!-- start-cryptonite-private-code -->',
end_block: '<!-- end-cryptonite-private-code -->'
}
]
},
your_target: {
// a list of files you want to strip code from
src: ['../cryptonite/src/js/**/*.js', '../cryptonite/src/html/**/*.*']
}
},
shell: {
copyInternalCryptonite: {
command: function() {
var commandToExecute;
commandToExecute = [
'rsync -av . ../cryptonite --exclude .git --exclude .DS_Store --exclude node_modules --exclude package-lock.json --exclude src.pem --exclude signing',
'rm -rfd ../cryptonite/node_modules'
].join('&&');
return commandToExecute;
},
options: {
stdout: true,
stderr: true
}
},
}
});
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-strip-code');
grunt.registerTask("cryptonite-jslint", "Execute a jslint scan over the whole codebase", function() {
var outputToConsole = grunt.option('c') || '';
grunt.task.run("exec:jslint:" + outputToConsole);
});
grunt.registerTask("update-repo", "", function() {
grunt.task.run("shell:copyInternalCryptonite");
grunt.task.run("strip_code");
});
grunt.registerTask('default', ['jsdoc', 'jslint', 'exec:jslint']);
};