-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
118 lines (114 loc) · 2.91 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
'use strict';
module.exports = function(grunt) {
var TEST_SERVER_PORT = process.env.TEST_SERVER_PORT || 4000;
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
standalone: {
options: {
transform: ['browserify-shim'],
bundleOptions: {
standalone: 'ReactTemplate'
}
},
files: {
'./browser-builds/react-template.js': './lib/index.js'
}
}
},
uglify: {
browserbuilds: {
files: [
{
expand: true,
cwd: './browser-builds/',
src: '**/*.js',
dest: './browser-builds/'
}
]
}
},
connect: {
options: {
port: TEST_SERVER_PORT,
base: '.'
},
tests: {
options: {
keepalive: false
}
},
testskeepalive: {
options: {
keepalive: true
}
}
},
mocha: {
all: {
options: {
run: true,
log: true,
logErrors: true,
reporter: 'Spec',
urls: ["http://localhost:" + TEST_SERVER_PORT + "/test/index.html"],
mocha: {
grep: grunt.option('grep')
}
}
}
},
mochaTest: {
test: {
options: {
reporter: 'Spec',
clearRequireCache: true,
grep: grunt.option('grep')
},
src: ['test/**/*.js']
}
},
watch: {
options: {
atBegin: true
},
lib: {
files: ['lib/**/*.js'],
tasks: ['build:standalone']
}
},
bump: {
options: {
files: ['package.json', 'bower.json'],
commit: true,
commitFiles: ['-a'],
createTag: true,
push: false
}
}
});
// Load Grunt plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Define tasks.
grunt.registerTask('build', ['build:standalone']);
grunt.registerTask('build:standalone', ['browserify']);
grunt.registerTask('default', ['build']);
grunt.registerTask('test:phantom', ['build:standalone', 'connect:tests', 'mocha']);
grunt.registerTask('test:browser', ['build:standalone', 'connect:testskeepalive']);
grunt.registerTask('test:server', ['settestglobals', 'mochaTest']);
grunt.registerTask('test', ['test:phantom', 'settestglobals', 'mochaTest']);
return grunt.registerTask('settestglobals', function() {
// Sets globals for the server tests so we can use the same module for
// browser tests.
GLOBAL.chai = require('chai');
GLOBAL.ReactTemplate = require('./lib/index');
GLOBAL.React = require('react');
});
};