-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
40 lines (38 loc) · 1.02 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
const gulp = require( 'gulp' );
const grename = require( 'gulp-rename' );
const gzip = require( 'gulp-zip' );
const packageJson = require( './package.json' );
async function zip( snapshot = false ) {
let suffix;
if (snapshot) {
suffix = await new Promise( ( resolve, reject ) => {
const { exec } = require( 'child_process' );
exec( 'git rev-parse --abbrev-ref HEAD', ( err, stdout, stderr ) => {
if (err) {
reject( err );
}
resolve( stdout.trim() );
} );
} );
suffix = suffix.replace( /[\\~#%&*{}/:<>?|\"]/g, '' ) + '-SNAPSHOT';
} else {
suffix = 'v' + packageJson.version;
}
return gulp.src( [
'build/*',
'php/*',
'res/*',
'gb-fullcalendar.php',
'package.json',
'README.md',
'CHANGELOG.md',
'LICENSE.md',
], { base: './' } )
.pipe( grename( function( file ) {
file.dirname = 'gb-fullcalendar/' + file.dirname;
} ) )
.pipe( gzip( `gb-fullcalendar-${ suffix }.zip` ) )
.pipe( gulp.dest( 'dist' ) );
}
exports.zip = () => zip( false );
exports.zipSnapshot = () => zip( true );