forked from microsoft/vscode-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
105 lines (90 loc) · 3.12 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
/*---------------------------------------------------------------------------------------------
* 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 git = require('gulp-git');
var fs = require('fs');
var runSequence = require('run-sequence');
var rimraf = require('rimraf');
var common = require('./scripts/gulpfile.common.js');
var imagemin = require('gulp-imagemin');
require('./scripts/gulpfile.docs.js');
require('./scripts/gulpfile.releasenotes.js');
require('./scripts/gulpfile.api.js');
require('./scripts/gulpfile.blog.js');
require('./scripts/gulpfile.tutorial.js');
var BRANCH = process.env["branch"] ? process.env["branch"] : "master";
var URL = process.env["token"] ? 'https://' + process.env["token"] + '@github.com/microsoft/vscode-website' : 'https://github.com/microsoft/vscode-website';
gulp.task('compile-all', ['compile-docs', 'compile-releasenotes', 'compile-blog', 'compile-tutorial']);
gulp.task('clean-out-folder', common.rimraf('out'));
gulp.task('clone-vscode-website', ['clean-out-folder'], function (cb) {
fs.mkdir('out');
process.chdir('./out');
git.clone(URL, function (err) {
if (err) {
console.log('could not clone vscode-website')
console.log(err);
cb(err);
} else {
process.chdir('./vscode-website');
git.checkout(BRANCH, function (error) {
console.log('checked out branch:', BRANCH);
process.chdir('../../');
cb(error);
});
}
});
});
gulp.task('commit', function () {
process.chdir('./out/vscode-website');
return gulp.src(['./*'], { buffer: false })
.pipe(git.add())
.pipe(git.commit('syncing with vscode-docs'))
});
gulp.task('push', function (cb) {
git.push(URL, BRANCH, { args: "-f" }, function (error) {
if (!error) {
console.log('successfully pushed to branch:', BRANCH);
}
cb(error);
});
});
gulp.task('build-website', function (cb) {
runSequence('compile',
'clone-vscode-website',
'generate-api-doc',
'compile-all');
});
gulp.task('publish-releasenotes', function (cb) {
runSequence('checkout-master',
'copy-releasenotes-raw-images',
'compile-releasenotes-markdown',
'compile-releasenotes-css'
);
});
gulp.task('checkout-master', function (cb) {
console.log('Checkout vscode-website master...');
process.chdir('./out/vscode-website');
git.checkout('master', function (error) {
console.log('checked out branch: master');
process.chdir('../../');
cb(error);
});
});
gulp.task('sync-master', ['commit'], function (cb) {
git.push(URL, 'master', { args: "-f" }, function (error) {
if (!error) {
console.log('successfully pushed to branch: master');
}
cb(error);
});
});
gulp.task('sync', function (cb) {
runSequence('commit', 'push');
});
gulp.task('minify-images', function () {
return gulp.src(['**/*.{png,jpg,svg}', '!node_modules/**'], { nocase: true })
.pipe(imagemin())
.pipe(gulp.dest('.'));
});