This repository has been archived by the owner on Sep 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathGruntfile.js
145 lines (137 loc) · 4.25 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
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
var browsers = require('./grunt/browsers');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
nodeunit: {
platform : ['test/platform-tests/node/*/runner.js']
},
karma: require('./grunt/config/karma/index.js')(grunt),
express: {
dev: {
options: {
node_env: 'development',
livereload: true,
script: 'grunt/server.js',
port: 3000
}
},
prod: {
options: {
node_env: 'production',
script: 'grunt/server.js',
port: 3000
}
},
"prod-require": {
options: {
node_env: 'production-require',
script: 'grunt/server.js',
port: 3000
}
},
"scxml" : {
options: {
port : 42000,
script: 'test/node-test-server.js',
args : grunt.option('legacy-semantics') ? ['--legacy-semantics'] : []
}
}
},
'saucelabs-custom': {
all: {
options: {
urls: [
'http://127.0.0.1:3000/'
],
browsers: browsers,
build: process.env.TRAVIS_JOB_ID,
testname: 'custom tests',
throttled: 5,
statusCheckAttempts : -1,
sauceConfig: {
'video-upload-on-pass': false
}
}
}
},
gitcommit: {
dist: {
options: {
message: 'Updated dist files',
},
files: {
src: [
'dist/scxml.js',
'dist/scxml.js.map',
'dist/scxml.min.js'
]
}
}
},
release: {
options: {
beforeRelease : ['build', 'gitcommit:dist'],
additionalFiles: ['bower.json']
}
},
run : {
build : {
exec : 'npm run build'
}
},
watch: {
options: {
livereload: false
},
express: {
files: [ 'lib/**/*.js' ],
tasks : ['build'],
options: {
spawn: false
}
},
public: {
files: [""]
}
}
});
grunt.registerTask('mywatch',['express:dev:start','watch:express']);
grunt.registerTask('mywatch-prod',['build','express:prod:start','watch:express']);
grunt.registerTask('replace-reserved-words', 'String replace reserved words in built JavaScript.', function() {
var fs = require('fs');
var fileContents = fs.readFileSync('dist/scxml.js','utf8');
['return','delete'].forEach(function(s){
fileContents = fileContents.replace(new RegExp('\\.\\b' + s + '\\b','g'), '["' + s + '"]');
});
fs.writeFileSync('dist/scxml.js', fileContents);
});
grunt.registerTask('scxml-test-client', 'Run scxml tests in node. ', function(){
const legacySemantics = grunt.option('legacy-semantics');
console.log('legacySemantics',legacySemantics);
const scxmlTestFiles =
grunt.file.expand(
require(legacySemantics ?
'./grunt/scxml-tests.legacySemantics.json' :
'./grunt/scxml-tests.json'));
var done = this.async();
//TODO: convert to submodule.
var startTests = require('scxml-test-framework');
startTests({
verbose : false,
report : 'console',
legacySemantics : legacySemantics,
scxmlTestFiles : scxmlTestFiles
}, done);
});
//TODO: copy babel-polyfill and nodeunit-browser into test/harness/browser/lib. I wish these were published via bower.
grunt.task.registerTask('test-semantics', ['express:scxml', 'scxml-test-client', 'express:scxml:stop']);
grunt.registerTask('build', [ 'run:build']);
grunt.registerTask('default', ['build']);
grunt.registerTask('test-node', ['nodeunit:platform', 'test-semantics']);
grunt.registerTask('test', [
'test-node'
]);
grunt.registerTask('run-browser-tests-dev', ['express:dev', 'saucelabs-custom', 'express:dev:stop' ]);
grunt.registerTask('run-browser-tests-prod', ['express:prod', 'saucelabs-custom', 'express:prod:stop' ]);
};