-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
67 lines (54 loc) · 1.9 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
const del = require('del');
const exec = require('child_process').exec;
const eventStream = require('event-stream');
const gulp = require('gulp');
let changeFileName = (eventStream) => {
return eventStream.map((file, callback) => {
let filePath = file.path.substring(0, file.path.indexOf('src'));
let fileName = file.path.substring(file.path.indexOf('src') + 4).split('\\').join('-');
file.path = filePath + 'dist\\' + fileName;
return callback(null, file)
});
};
gulp.task('clean-dist', () => {
return del('dist/**', { force: true });
});
gulp.task('clean-publish', () => {
return del('publish/**', { force: true });
});
gulp.task('copy-html', () => {
return gulp.src('src/**/*.html')
.pipe(changeFileName(eventStream))
.pipe(gulp.dest('dist'));
});
gulp.task('copy-js', () => {
return gulp.src('src/**/*.js')
.pipe(changeFileName(eventStream))
.pipe(gulp.dest('dist'));
});
gulp.task('copy-libs', () => {
return gulp.src('node_modules/chart.js/dist/**/*.js')
.pipe(gulp.dest('dist/lib'));
});
gulp.task('create-extension-rev', (done) => {
exec('tfx extension create --rev-version --manifests vss-extension.json --output-path ./publish', (err, stdOut, stdErr) => {
console.log(stdOut);
if (err){
done(err);
} else {
done();
}
});
});
gulp.task('create-extension', (done) => {
exec('tfx extension create --manifests vss-extension.json --output-path ./publish', (err, stdOut, stdErr) => {
console.log(stdOut);
if (err){
done(err);
} else {
done();
}
});
});
gulp.task('default', gulp.series('clean-dist', 'copy-libs', 'copy-js', 'copy-html', 'clean-publish', 'create-extension-rev'));
gulp.task('pack', gulp.series('clean-dist', 'copy-libs', 'copy-js', 'copy-html', 'clean-publish', 'create-extension'));