-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
91 lines (82 loc) · 2.38 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifyCSS = require('gulp-minify-css'),
rigger = require('gulp-rigger'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
browserSync = require("browser-sync"),
argv = require('yargs').argv,
rename = require('gulp-rename'),
reload = browserSync.reload;
var root = '.';
var pluginPath = root + '/wp-content/plugins/woo-shipping-for-nova-poshta';
var svnPath = root + '/svn.wordpress.org';
var assetsPath = pluginPath + '/assets';
var path = {
build: {
js: assetsPath + '/js',
css: assetsPath + '/css',
screenShots: svnPath + '/assets'
},
src: {
js: root + '/src/js/*.js',
sass: root + '/src/sass/**/*.scss',
screenShots: root + '/src/screenshot/*.png'
},
watch: {
js: root + '/src/js/**/*.js',
sass: root + '/src/sass/**/*.scss'
}
};
gulp.task('js', function () {
gulp.src(path.src.js)
.pipe(rigger())
.pipe(gulp.dest(path.build.js))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(path.build.js))
.pipe(reload({stream: true}));
});
gulp.task('sass', function () {
gulp.src(path.src.sass)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(path.build.css))
.pipe(minifyCSS({keepBreaks: true}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(path.build.css));
});
gulp.task('watch', function () {
watch([path.watch.js], function () {
gulp.start('js').start('sass');
});
});
gulp.task('build', [
'js',
'sass'
]);
gulp.task('default', [
'js',
'sass',
'watch'
]);
gulp.task('svn:push', function () {
gulp.src(pluginPath + '/**/*')
.pipe(gulp.dest(svnPath + '/trunk'));
gulp.src(pluginPath + '/**/.*')
.pipe(gulp.dest(svnPath + '/trunk'));
//move screen shots to assets folder
gulp.src(path.src.screenShots)
.pipe(gulp.dest(path.build.screenShots))
.pipe(reload({stream: true}));
});
gulp.task('svn:tag', function () {
var tag = argv.t;
if (!tag) {
throw Error("Tag is undefined. Please set arg --t");
}
var destinationPath = svnPath + '/tags/' + tag;
gulp.src(pluginPath + '/**/*')
.pipe(gulp.dest(destinationPath));
gulp.src(pluginPath + '/**/.*')
.pipe(gulp.dest(destinationPath));
});