This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
gulpfile.js
102 lines (89 loc) · 3.5 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
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var del = require('del');
var mocha = require('gulp-mocha');
var tar = require('gulp-tar');
var gzip = require('gulp-gzip');
var merge = require('merge2');
var minimist = require('minimist');
var typescript = require('gulp-tsc');
var buildRoot = path.join(__dirname, '_build');
var tarRoot = path.join(__dirname, '_tar');
var packageRoot = path.join(__dirname, '_package');
var testRoot = path.join(__dirname, '_test');
var testPath = path.join(testRoot, 'test');
var buildPath = path.join(buildRoot, 'vsoxplat');
var packagePath = path.join(packageRoot, 'vsoxplat');
var binPath = path.join(buildPath, 'bin');
var agentPath = path.join(buildPath, 'agent');
var handlerPath = path.join(agentPath, 'handlers');
var pluginPath = path.join(agentPath, 'plugins');
var buildPluginPath = path.join(pluginPath, 'build');
var buildPluginLibPath = path.join(buildPluginPath, 'lib');
var scmLibPath = path.join(agentPath, 'scm', 'lib');
var mopts = {
boolean: 'ci',
string: 'suite',
default: { ci: false, suite: '*' }
};
var options = minimist(process.argv.slice(2), mopts);
gulp.task('copy', ['clean'], function () {
return merge([
gulp.src(['admin/publish.sh']).pipe(gulp.dest(packageRoot)),
gulp.src(['admin/package.sh']).pipe(gulp.dest(packageRoot)),
gulp.src(['admin/createpackages.sh']).pipe(gulp.dest(packageRoot)),
gulp.src(['getagent.sh']).pipe(gulp.dest(buildPath)),
gulp.src(['run.sh']).pipe(gulp.dest(buildPath)),
gulp.src(['configure.sh']).pipe(gulp.dest(buildPath)),
gulp.src(['package.json']).pipe(gulp.dest(buildPath)),
gulp.src(['src/agent/svc.sh']).pipe(gulp.dest(agentPath)),
gulp.src(['src/agent/plugins/build/lib/askpass.js']).pipe(gulp.dest(buildPluginLibPath)),
gulp.src(['src/agent/scm/lib/credhelper.js']).pipe(gulp.dest(scmLibPath)),
gulp.src(['src/agent/scm/lib/gitw.js']).pipe(gulp.dest(scmLibPath)),
gulp.src(['src/bin/install.js']).pipe(gulp.dest(binPath))
]);
});
gulp.task('build', ['copy'], function () {
return gulp.src(['src/**/*.ts'])
.pipe(typescript())
.pipe(gulp.dest(buildPath));
});
gulp.task('testPrep', ['build'], function () {
var buildSrc = gulp.src([path.join(buildPath, '**')]);
var testSrcPaths = ['src/test/messages/**',
'src/test/projects/**',
'src/test/tasks/**',
'src/test/scripts/**',
'src/test/testresults/**',
'src/test/codecoveragefiles/**',
'src/vso-task-lib/**',
'!src/test/definitions'];
return merge([
buildSrc.pipe(gulp.dest(testRoot)),
gulp.src(testSrcPaths, { base: 'src/test' })
.pipe(gulp.dest(testPath))
]);
});
gulp.task('test', ['testPrep'], function () {
var suitePath = path.join(testPath, '*.js');
if (options.suite !== '*') {
suitePath = path.join(testPath, options.suite + '.js');
}
return gulp.src([suitePath])
.pipe(mocha({ reporter: 'spec', ui: 'bdd', useColors: !options.ci }));
});
gulp.task('package', ['build'], function () {
return gulp.src([path.join(buildPath, '**'), 'README.md'])
.pipe(gulp.dest(packagePath));
});
gulp.task('tar', ['package'], function () {
return gulp.src(path.join(packagePath, '**'))
.pipe(tar('vsoxplat.tar'))
.pipe(gzip())
.pipe(gulp.dest(tarRoot));
});
gulp.task('clean', function (done) {
del([buildRoot, tarRoot, packageRoot, testRoot], done);
});
gulp.task('default', ['tar']);