This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
75 lines (62 loc) · 1.99 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
// # Gruntfile
// Automation for the project.
'use strict';
var GruntConfig = require('thehelp-project').GruntConfig;
require('thehelp-client-project').mixin(GruntConfig);
var internals = {};
module.exports = function(grunt) {
var config = new GruntConfig(grunt);
config.standardSetup();
config.registerCopy();
internals.setupDist(config, grunt);
internals.setupClientTesting(config, grunt);
// This is what runs when you type just 'grunt' on the command line
var tasks = config.defaultTasks.concat(['dist', 'client-test']);
grunt.registerTask('default', tasks);
};
/*
`setupDist` contains all the grunt registration required to assemble
the dist folder, for users of `thehelp-core` on the client side:
1. optimize thehelp-core.js
2. copy all shims to 'dist/shims' folder
*/
internals.setupDist = function(config, grunt) {
var requireJsOptions = require('./src/client/config');
var optimize = {
source: 'thehelp-core',
targetPath: 'dist',
empty: ['winston', 'util'],
config: requireJsOptions
};
config.registerOptimizeLibrary(optimize);
grunt.config('copy.shims-to-dist', {
files: [{
expand: true,
cwd: 'src/client/shims',
src: ['*.js'],
dest: 'dist/shims'
}]
});
config.registerPreambleForDist({
src: ['dist/thehelp-core*', 'dist/shims/*shim.js']
});
grunt.registerTask('dist', ['copy:shims-to-dist', 'requirejs', 'preamble-for-dist']);
};
// `setupClientTest` provides a 'client-test' task that runs client-side tests
// via `phantomjs`.
internals.setupClientTesting = function(config, grunt) {
config.registerMocha({
urls: [
'http://localhost:3001/test/integration/dev.html',
'http://localhost:3001/test/integration/dist.html'
]
});
grunt.registerTask('client-test', ['connect:test', 'mocha']);
config.registerSauce({
urls: [
'http://localhost:3001/test/integration/dist.html'
],
browsers: config.saucePlatforms.all
});
grunt.registerTask('cross-browser', ['client-test', 'sauce']);
};