forked from Azure/azure-openapi-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (85 loc) · 3.61 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var path = require('path');
var gulp = require('gulp');
var clean = require('gulp-clean');
var run = require('gulp-run')
var mocha = require('gulp-mocha');
var { restore, build, test, pack, publish } = require('gulp-dotnet-cli');
// add .bin to PATH
function getPathVariableName() {
// windows calls it's path 'Path' usually, but this is not guaranteed.
if (process.platform === 'win32') {
for (const key of Object.keys(process.env))
if (key.match(/^PATH$/i))
return key;
return 'Path';
}
return "PATH";
}
process.env[getPathVariableName()] = path.join(__dirname, "src/dotnet/AutoRest/node_modules/.bin") + path.delimiter + process.env[getPathVariableName()];
// All the typescript tasks
gulp.task('clean/typescript', function () {
console.log('Cleaning build directories...');
return gulp.src(['src/typescript/azure-openapi-validator/*.{js,d.ts}', 'src/typescript/jsonrpc/*.{js,d.ts}'], { read: false })
.pipe(clean({ force: true }));
});
gulp.task('build/typescript', ['clean/typescript'], function () {
console.log('Running the typescript transpiler...');
return gulp.src('./src/typescript/').pipe(run('tsc --project tsconfig.json'));
});
gulp.task('test/typescript', ['build/typescript'], function () {
console.log('Running the unit tests...');
gulp.src(['src/typescript/azure-openapi-validator/tests/*.js'])
.pipe(mocha({
timeout: 120000
}))
.once('error', () => {
process.exit(1);
});
});
// All the dotnet tasks
gulp.task('clean/dotnet', function () {
console.log('Cleaning build directories...');
return gulp.src(['src/dotnet/**/bin', 'src/dotnet/**/obj'], { read: false })
.pipe(clean({ force: true }));
});
gulp.task('restore/dotnet', ['clean/dotnet'], function () {
console.log('Running dotnet restore...');
return gulp.src('src/dotnet/**/*.csproj')
.pipe(restore());
});
gulp.task('build/dotnet', ['restore/dotnet'], function () {
console.log('Running dotnet build...');
return gulp.src('src/dotnet/**/*.csproj')
.pipe(build());
});
gulp.task('test/dotnet', ['build/dotnet'], function () {
console.log('Running the dotnet unit tests...');
return gulp.src('src/dotnet/OpenAPI.Validator.Tests/OpenAPI.Validator.Tests.csproj')
.pipe(test({ verbosity: 'minimal' }));
});
// Now the defaults/commons
gulp.task('build', ['build/dotnet', 'build/typescript'], function () {
console.log('Building code...');
});
gulp.task('clean', ['clean/typescript', 'clean/dotnet'], function () {
console.log('Cleaning artifacts...');
});
gulp.task('test', ['test/dotnet', 'test/typescript'], function () {
console.log('Successfully ran the tests...');
});
gulp.task('dotnet', ['test/dotnet'], function () {
});
gulp.task('typescript', ['test/typescript'], function () {
});
gulp.task('default', ['dotnet', 'typescript'], function () {
console.log('Successfully built and tested the repo...');
});
gulp.task('dotnet/pack', ['dotnet', 'typescript'], function () {
console.log('Kicking off the dotnet publish task...');
return gulp.src('src/dotnet/AutoRest/AutoRest.csproj')
.pipe(run('dotnet publish src/dotnet/AutoRest/AutoRest.csproj --configuration release --output bin/netcoreapp2.0'));
});