-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
79 lines (67 loc) · 2.46 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
const path = require("path");
const gulp = require('gulp');
const clean = require("gulp-clean");
const yargs = require("yargs");
const {execSync, exec} = require('child_process');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const tslint = require('gulp-tslint');
const inlinesource = require('gulp-inline-source');
const args = yargs.argv;
const distFolder = 'dist';
gulp.task('clean', gulp.series(() => {
return gulp.src([distFolder, '*.vsix'], {allowEmpty: true})
.pipe(clean());
}));
gulp.task('tslint', gulp.series(() => {
return gulp.src(["scripts/**/*ts", "scripts/**/*tsx"])
.pipe(tslint({
formatter: "verbose",
fix: true,
}))
.pipe(tslint.report());
}));
gulp.task('styles', gulp.parallel(async () => {
execSync("node ./node_modules/sass/sass.js ./styles/attachmentGroup.scss ./dist/attachmentGroup.css", {
stdio: [null, process.stdout, process.stderr]
});
}, async () => {
execSync("node ./node_modules/sass/sass.js ./styles/imageGallery.scss ./dist/imageGallery.css", {
stdio: [null, process.stdout, process.stderr]
});
}
));
gulp.task('copy', gulp.series(() => {
return gulp.src('node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js')
.pipe(gulp.dest(distFolder));
}));
gulp.task('build', gulp.series(gulp.parallel('styles', 'tslint', 'copy'), () => {
const option = yargs.argv.release ? "-p" : "-d";
execSync(`node ./node_modules/webpack-cli/bin/cli.js ${option}`, {
stdio: [null, process.stdout, process.stderr]
});
return gulp.src("*.html")
.pipe(inlinesource())
.pipe(gulp.dest(distFolder));
}));
gulp.task('package', gulp.series('clean', 'build', async () => {
const overrides = {}
if (yargs.argv.release) {
overrides.public = true;
} else {
const manifest = require('./vss-extension.json');
overrides.name = manifest.name + ": Development Edition";
overrides.id = manifest.id + "-dev";
}
const overridesArg = `--override "${JSON.stringify(overrides).replace(/"/g, '\\"')}"`;
const manifestsArg = `--manifests vss-extension.json`;
exec(`tfx extension create ${overridesArg} ${manifestsArg} --rev-version`,
(err, stdout, stderr) => {
if (err) {
console.log(err);
}
console.log(stdout);
console.log(stderr);
});
}));
gulp.task('default', gulp.series('package'));