-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (50 loc) · 1.35 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const rimraf = require('rimraf');
const runCmd = require('./utils/runCmd');
const { execSync } = require('child_process');
const packageJson = require('./package.json');
function tag() {
console.log('tagging');
const { version } = packageJson;
execSync(`git tag ${version}`);
execSync(`git push origin ${version}:${version}`);
execSync('git push origin master:master');
console.log('tagged');
}
gulp.task('default', (done) => {
rimraf.sync('lib');
gulp.src('src/**/*.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(gulp.src('src/**/*.d.ts'))
.pipe(gulp.dest('lib'))
.on('finish', done)
});
gulp.task(
'check-git',
gulp.series(done => {
runCmd('git', ['status', '--porcelain'], (code, result) => {
if (/^\?\?/m.test(result)) {
return done(`There are untracked files in the working tree.\n${result}
`);
}
if (/^([ADRM]| [ADRM])/m.test(result)) {
return done(`There are uncommitted changes in the working tree.\n${result}
`);
}
return done();
});
})
);
gulp.task('publish',
gulp.series('check-git', 'default', done => {
tag();
runCmd('npm', ['publish'], (code) => {
console.log(`npm publish version ${packageJson.version} successfully`);
done(code);
});
done();
})
)