forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
151 lines (133 loc) · 3.49 KB
/
gulpfile.js
File metadata and controls
151 lines (133 loc) · 3.49 KB
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
145
146
147
148
149
150
151
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var stylish = require('gulp-jscs-stylish');
var path = require('path');
var karma = require('karma');
function runTests(singleRun, isCI, done) {
var reporters = ['mocha'];
var preprocessors = {};
var files = [
path.join(__dirname, 'test/vendor/*.js'), // PhantomJS 1.x polyfills
path.join(__dirname, 'github.js'),
path.join(__dirname, 'test/test.*.js')
];
if (singleRun) {
files.forEach(function(path) {
preprocessors[path] = ['coverage'];
});
reporters.push('coverage');
}
files.push(path.join(__dirname, 'test/user.json'));
files.push({
pattern: path.join(__dirname, 'test/gh.png'),
watched: false,
included: false
});
preprocessors['test/user.json'] = ['json_fixtures'];
var localConfig = {
files: files,
configFile: path.join(__dirname, './karma.conf.js'),
singleRun: singleRun,
autoWatch: !singleRun,
reporters: reporters,
preprocessors: preprocessors
};
if (isCI) {
localConfig.sauceLabs = {
testName: 'GitHub.js UAT tests',
idleTimeout: 120000,
recordVideo: false
};
// Increase timeouts massively so Karma doesn't timeout in Sauce tunnel.
localConfig.browserNoActivityTimeout = 400000;
localConfig.captureTimeout = 120000;
localConfig.customLaunchers = sauceLaunchers;
localConfig.browsers = Object.keys(sauceLaunchers);
reporters.push('saucelabs');
// Set Mocha timeouts to longer.
localConfig.client = {
mocha: {
timeout: 20000
}
};
}
var server = new karma.Server(localConfig, function(failCount) {
done(failCount ? new Error('Failed ' + failCount + ' tests.') : null);
});
server.start();
} // End runTests()
gulp.task('lint', function() {
return gulp.src([
path.join(__dirname, '/*.js'),
path.join(__dirname, '/test/*.js')
],
{
base: './'
})
.pipe(jshint())
.pipe(jscs({
fix: true
}))
.pipe(stylish.combineWithHintResults())
.pipe(jscs.reporter())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(gulp.dest('.'));
});
gulp.task('test', function(done) {
runTests(true, false, done);
});
gulp.task('test:ci', function(done) {
runTests(true, true, done);
});
gulp.task('test:auto', function(done) {
runTests(false, false, done);
});
gulp.task('build', function() {
return gulp.src('github.js')
.pipe(uglify())
.pipe(rename('github.min.js'))
.pipe(gulp.dest('dist/'));
});
gulp.task('default', function() {
gulp.start('lint', 'test', 'build');
});
var sauceLaunchers = {
SL_Chrome: {
base: 'SauceLabs',
browserName: 'chrome',
version: '45'
},
SL_Firefox: {
base: 'SauceLabs',
browserName: 'firefox',
version: '39'
},
SL_Safari: {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.10',
version: '8'
},
SL_IE_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 2012',
version: '10'
},
SL_IE_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11'
},
SL_iOS: {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '8.1'
}
};