forked from DevExpress/testcafe-browser-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
119 lines (101 loc) · 3.11 KB
/
Gulpfile.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
var path = require('path');
var childProcess = require('child_process');
var gulp = require('gulp');
var babel = require('gulp-babel');
var eslint = require('gulp-eslint');
var flatten = require('gulp-flatten');
var mocha = require('gulp-mocha');
var msbuild = require('gulp-msbuild');
var del = require('del');
var through = require('through2');
var Promise = require('promise');
var exec = Promise.denodeify(childProcess.exec);
// Windows bin
gulp.task('clean-win-bin', function (cb) {
del('bin/win', cb);
});
gulp.task('build-win-executables', ['clean-win-bin'], function () {
return gulp
.src('src/**/*.csproj')
.pipe(msbuild({
targets: ['Clean', 'Build']
}));
});
gulp.task('copy-win-executables', ['build-win-executables'], function () {
return gulp
.src('src/**/win/bin/Release/*.exe')
.pipe(flatten())
.pipe(gulp.dest('bin/win'));
});
// Mac bin
gulp.task('clean-mac-bin', function (callback) {
del('bin/mac', callback);
});
gulp.task('build-mac-executables', ['clean-mac-bin'], function () {
function make (options) {
return through.obj(function (file, enc, callback) {
if (file.isNull()) {
callback(null, file);
return;
}
var dirPath = path.dirname(file.path);
exec('make -C ' + dirPath, { env: options })
.then(function () {
callback(null, file);
})
.catch(callback);
});
}
return gulp
.src('src/**/mac/Makefile')
.pipe(make({
DEST: path.join(__dirname, 'bin/mac')
}));
});
gulp.task('copy-mac-scripts', ['clean-mac-bin'], function () {
return gulp
.src('src/**/mac/*.scpt')
.pipe(flatten())
.pipe(gulp.dest('bin/mac'));
});
// Test
gulp.task('run-playground-win', ['build-win'], function () {
require('./test/playground/index');
});
gulp.task('run-playground-mac', ['build-mac'], function () {
require('./test/playground/index');
});
gulp.task('test-lib', ['build-lib'], function () {
return gulp
.src('test/tests/*-test.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
}));
});
gulp.task('test', ['lint', 'test-lib']);
// General tasks
gulp.task('lint', function () {
return gulp
.src([
'src/**/*.js',
'test/**/*.js',
'!test/playground/public/**/*',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('clean-lib', function (cb) {
del('lib', cb);
});
gulp.task('build-lib', ['clean-lib'], function () {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('build-win', ['build-lib', 'copy-win-executables']);
gulp.task('build-mac', ['build-lib', 'build-mac-executables', 'copy-mac-scripts']);