forked from arlolra/otr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
104 lines (96 loc) · 2.87 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
module.exports = function (grunt) {
"use strict";
var cryptojs = [
'vendor/cryptojs/header.js'
, 'vendor/cryptojs/core.js'
, 'vendor/cryptojs/enc-base64.js'
, 'vendor/cryptojs/cipher-core.js'
, 'vendor/cryptojs/aes.js'
, 'vendor/cryptojs/sha1.js'
, 'vendor/cryptojs/sha256.js'
, 'vendor/cryptojs/hmac.js'
, 'vendor/cryptojs/pad-nopadding.js'
, 'vendor/cryptojs/mode-ctr.js'
, 'vendor/cryptojs/footer.js'
]
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-jshint')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
, meta: {
banner:
'/*!\n\n <%= pkg.name %>.js v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
' (c) <%= grunt.template.today("yyyy") %> - <%= pkg.author %>\n' +
' Freely distributed under the <%= pkg.license %> license.\n\n' +
' This file is concatenated for the browser.\n' +
' Please see: <%= pkg.homepage %>' +
'\n\n*/\n\n'
}
, concat: {
otr: {
options: {
banner: '<%= meta.banner %>'
}
, src: [
'etc/header.js'
, 'lib/const.js'
, 'lib/helpers.js'
, 'lib/dsa.js'
, 'lib/parse.js'
, 'lib/ake.js'
, 'lib/sm.js'
, 'lib/otr.js'
, 'etc/footer.js'
]
, dest: 'build/otr.js'
}
, cryptojs: {
src: cryptojs
, dest: 'vendor/crypto.js'
}
}
, uglify: {
otr: {
options: {
banner: '<%= meta.banner %>'
, mangle: false
},
files: {
'build/otr.min.js': ['build/otr.js']
}
}
}
, clean: {
folder: 'build/'
}
, jshint: {
options: {
jshintrc: '.jshintrc'
}
, all: ['*.js', 'lib/*.js', 'test/spec/unit/*.js']
}
})
grunt.registerTask('copy_dep', function () {
var files = ['salsa20.js', 'bigint.js', 'eventemitter.js', 'crypto.js']
, src = 'vendor/'
, dest = 'build/dep/'
files.forEach(function (f) {
grunt.file.copy(src + f, dest + f)
})
})
grunt.registerTask('copy_ww', function () {
var files = ['dsa-webworker.js', 'sm-webworker.js']
, src = 'lib/'
, dest = 'build/'
files.forEach(function (f) {
grunt.file.copy(src + f, dest + f)
})
})
grunt.registerTask('otr', ['concat:otr', 'uglify:otr'])
grunt.registerTask('dep', ['concat:cryptojs', 'copy_dep'])
grunt.registerTask('ww', ['copy_ww'])
grunt.registerTask('default', ['clean', 'otr', 'dep', 'ww'])
}