This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Gruntfile.js
134 lines (128 loc) · 3.95 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
var path = require('path');
var fs = require("fs");
var exists = fs.existsSync || path.existsSync;
var async = require("async");
var through = require('through');
module.exports = function(grunt) {
var pkg = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: pkg,
meta: {},
jshint: {
all: ['src/**/*.js'],
options: {
curly: true,
eqeqeq: true,
eqnull: true,
sub: true,
loopfunc: true
}
},
concat: {
crypto: {
src:[
"libs/cryptojs/cryptojs-core.js",
"libs/cryptojs/cryptojs-cipher-core.js",
"libs/cryptojs/cryptojs-sha1.js",
"libs/cryptojs/cryptojs-x64-core.js"
],
dest: "libs/generated/crypto.js"
}
},
'mocha_phantomjs': {
test: {
options: {
urls: [
"http://127.0.0.1:8200/test/browser/index.html?url=http://localhost:9999",
]
}
},
test_coverage: {
options:{
reporter: "json-cov",
file: 'rep/coverage.json',
urls: [
"http://127.0.0.1:8200/test/browser/index.html?url=http://localhost:9999&coverage=1"
]
}
}
},
connect: {
server: {
options: {
hostname: "*",
port: 8200,
base: '.'
}
}
},
browserify: {
// This browserify build be used by users of the module. It contains a
// UMD (universal module definition) and can be used via an AMD module
// loader like RequireJS or by simply placing a script tag in the page,
// which registers fhsync as a global var (the module itself registers as $fh.sync as well).
dist:{
//shim is defined inside package.json
src:['src/index.js'],
dest: 'dist/fh-sync.js',
options: {
standalone: 'fhsync'
}
},
// This browserify build can be required by other browserify that
// have been created with an --external parameter.
require: {
src:['src/index.js'],
dest: 'test/browser/fh-sync-latest-require.js',
options: {
alias:['./src/sync-client.js']
}
},
// These are the browserified tests. We need to browserify the tests to be
// able to run the mocha tests while writing the tests as clean, simple
// CommonJS mocha tests (that is, without cross-platform boilerplate
// code). This build will also include the testing libs chai, sinon and
// sinon-chai but must not include the module under test.
test: {
src: [ './test/browser/suite.js' ],
dest: './test/browser/browserified_tests.js',
options: {
external: [ './src/index.js' ],
// Embed source map for tests
debug: true
}
},
},
watch: {
browserify: {
files: ['src/**/*.js', 'test/tests/*.js'],
tasks: ['browserify'],
options: {
spawn: false
}
}
},
uglify: {
dist: {
"files": {
'dist/fh-sync.min.js': ['dist/fh-sync.js'],
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-text-replace');
//run tests in phatomjs
grunt.registerTask('test', ['jshint:all', 'browserify:dist', 'browserify:require', 'browserify:test', 'connect:server', 'mocha_phantomjs:test']);
grunt.registerTask('concat-core-sdk', ['jshint', 'concat:crypto', 'browserify:dist']);
grunt.registerTask('build', ['concat-core-sdk', 'uglify:dist']);
grunt.registerTask('default', ['jshint', 'concat-core-sdk', 'test', 'uglify:dist']);
};