-
Notifications
You must be signed in to change notification settings - Fork 5
/
gruntfile.js
127 lines (107 loc) · 3 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
'use strict';
var ab = require('asyncblock');
var config = require('./test/config.js');
if (ab.enableTransform(module)) {
return;
}
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.registerTask('webdriverUpdateIfNeeded', function() {
//ensures correct pinned Webdriver binaries in config.js exists, otherwise fetch them.
const webdriverComponentsDirectory = './node_modules/webdriver-manager/selenium/';
var needToRunShellWebdriverUpdate = false;
for ( var component in config.webdriverComponents ) {
var version = config.webdriverComponents[component];
if ( !grunt.file.exists(webdriverComponentsDirectory + component + '*' + version + '*') ) {
needToRunShellWebdriverUpdate = true;
break;
}
};
if (needToRunShellWebdriverUpdate) {
console.log('One ore more selenium binaries not found. Running shell:webdriverUpdate.');
grunt.task.run('shell:webdriverUpdate');
}
});
grunt.initConfig({
clean: {
build: 'build',
dist: 'dist'
},
copy: {
dist: {
expand: true,
cwd: 'build/develop/app',
src: ['*.js', '*.d.ts'],
dest: 'dist'
},
prepareModuleDefinition: {
expand: true,
cwd: 'dist',
src: 'protractor_sync.d.ts',
dest: 'dist',
options: {
process: function (content, srcpath) {
//Convert to an ambient module, which will allow it to be "required"
return content.replace(/export declare module protractor_sync/, 'declare module "protractor_sync"');
}
}
}
},
protractor: {
options: {
configFile: 'test/protractor.conf.js'
},
tests: {}
},
shell: {
webdriverUpdate: {
command: 'node ./node_modules/webdriver-manager/bin/webdriver-manager update' +
' --versions.chrome '+config.webdriverComponents['chromedriver'] +
' --versions.gecko '+config.webdriverComponents['geckodriver'] +
' --versions.standalone '+config.webdriverComponents['selenium-server-standalone']
},
webdriverStart: {
command: 'node ./node_modules/webdriver-manager/bin/webdriver-manager start'
}
},
ts: {
options: {
compiler: 'node_modules/typescript/bin/tsc'
},
build: {
tsconfig: 'tsconfig.json'
},
watchApp: {
tsconfig: 'tsconfig.json',
watch: '.'
}
},
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json')
},
all: {
src: [ 'app/**/*.ts', 'test/**/*.ts' ]
}
}
});
grunt.registerTask('build', [
'clean:build',
'ts:build'
]);
grunt.registerTask('develop', [
'ts:watchApp'
]);
grunt.registerTask('test', [
'webdriverUpdateIfNeeded',
'protractor:tests'
]);
grunt.registerTask('verify', [
'tslint:all'
]);
grunt.registerTask('package', [
'clean:dist',
'copy:dist',
'copy:prepareModuleDefinition'
]);
};