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 97
/
gulpfile.js
147 lines (118 loc) · 3.68 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
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var gulp = require('gulp');
var path = require('path');
var ts = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var tslint = require("gulp-tslint");
var filter = require('gulp-filter');
var uglify = require('gulp-uglify');
var del = require('del');
var typescript = require('typescript');
var tsProject = ts.createProject('./src/tsconfig.json', { typescript });
var nls = require('vscode-nls-dev');
var inlineMap = true;
var inlineSource = false;
var watchedSources = [
'src/**/*',
'!src/tests/data/**'
];
var scripts = [
'src/node/terminateProcess.sh'
];
var scripts2 = [
'src/node/debugInjection.js'
];
var outDest = 'out';
var webPackedDest = 'dist';
const transifexProjectName = 'vscode-extensions';
const transifexExtensionName = 'vscode-node-debug';
gulp.task('clean', () => {
return del(['out/**', 'dist/**', 'package.nls.*.json', 'node-debug-*.vsix', 'package-lock.json']);
});
gulp.task('internal-compile', () => {
return compile();
});
gulp.task('internal-copy-scripts', () => {
return gulp.src(scripts)
.pipe(gulp.dest(outDest + '/node'));
});
gulp.task('internal-minify-scripts', () => {
return gulp.src(scripts2)
.pipe(uglify())
.pipe(gulp.dest(outDest + '/node'));
});
// compile and copy everything to outDest
gulp.task('internal-build', gulp.series('internal-compile', 'internal-copy-scripts', 'internal-minify-scripts', done => {
done();
}));
gulp.task('build', gulp.series('clean', 'internal-build', done => {
done();
}));
gulp.task('default', gulp.series('build', done => {
done();
}));
gulp.task('compile', gulp.series('clean', 'internal-build', done => {
done();
}));
gulp.task('nls-bundle-create', () => {
var r = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js
.pipe(nls.createMetaDataFiles())
.pipe(nls.bundleMetaDataFiles('ms-vscode.node-debug', webPackedDest))
.pipe(nls.bundleLanguageFiles())
.pipe(filter('**/nls.*.json'));
return r.pipe(gulp.dest(webPackedDest));
});
gulp.task('prepare-for-webpack', gulp.series('clean', 'internal-minify-scripts', 'nls-bundle-create', done => {
done();
}));
gulp.task('watch', gulp.series('internal-build', done => {
//log('Watching build sources...');
gulp.watch(watchedSources, gulp.series('internal-build'));
done();
}));
gulp.task('translations-export', gulp.series('build', 'prepare-for-webpack', () => {
return gulp.src(['package.nls.json', path.join(webPackedDest, 'nls.metadata.header.json'), path.join(webPackedDest, 'nls.metadata.json')])
.pipe(nls.createXlfFiles(transifexProjectName, transifexExtensionName))
.pipe(gulp.dest(path.join('..', 'vscode-translations-export')));
}));
//---- internal
function compile() {
var r = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject()).js;
if (inlineMap && inlineSource) {
r = r.pipe(sourcemaps.write());
} else {
r = r.pipe(sourcemaps.write("../out", {
// no inlined source
includeContent: inlineSource,
// Return relative source map root directories per file.
sourceRoot: "../src"
}));
}
return r.pipe(gulp.dest(outDest));
}
var allTypeScript = [
'src/**/*.ts'
];
var tslintFilter = [
'**',
'!**/*.d.ts'
];
gulp.task('tslint', done => {
gulp.src(allTypeScript)
.pipe(filter(tslintFilter))
.pipe(tslint({
formatter: "prose",
rulesDirectory: "node_modules/tslint-microsoft-contrib"
}))
.pipe(tslint.report( {
emitError: false
}));
done();
});