-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (102 loc) · 2.89 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
let nameSuffix = 'j_dyczka-m_mika';
const gulp = require('gulp'),
fs = require('fs'),
download = require('gulp-download'),
request = require('request'),
cheerio = require('cheerio'),
fsc = require('fs-cheerio'),
argv = require('yargs').argv,
gutil = require('gulp-util')
sass = require('gulp-sass')
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create(),
del = require('del'),
run = require('gulp-run')
zip = require('gulp-zip');
var prodNum = argv.nr;
gulp.task('clean', function() {
return del.sync(['zadanie-*']);
});
gulp.task('get', function() {
request('https://restcountries.eu/rest/v2/all', function(err,resp,data) {
if (!err) {
fs.writeFile( 'src/countriesInfo.json', data, function(err){} );
} else {
gutil.log('ERR', err);
}
});
});
gulp.task('sass', function() {
return gulp.src('src/style.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(autoprefixer({
browsers: ['last 3 versions'],
cascade: false
}))
.pipe(gulp.dest('zadanie-1'));
});
gulp.task('xml-1', function() {
return run('node ./src/generateXml-1').exec();
});
gulp.task('xml-2', function() {
return run('node ./src/generateXml-2').exec();
});
gulp.task('dtd', function() {
return gulp.src('src/doc.dtd')
.pipe(gulp.dest('zadanie-1'));
});
gulp.task('xsd', function() {
return gulp.src('src/*.xsd')
.pipe(gulp.dest('zadanie-2'));
});
gulp.task('zip-1', ['sass', 'xml'], function() {
gulp.src('src/zadanie-1')
.pipe(zip(`zadanie_1-${nameSuffix}.zip`))
.pipe(gulp.dest('zadanie-1'))
});
gulp.task('zip-2', ['sass', 'xml'], function() {
gulp.src('src/zadanie-2')
.pipe(zip(`zadanie_2-${nameSuffix}.zip`))
.pipe(gulp.dest('zadanie-2'))
});
gulp.task('default', function () {
gulp.start(
'sass',
'xml-1',
'xml-2',
'dtd',
'xsd'
);
});
gulp.task('watch-sass', ['sass'], function(done){
browserSync.reload();
done();
});
gulp.task('watch-xml', ['xml'], function(done){
browserSync.reload();
done();
});
gulp.task('watch-dtd', ['dtd'], function(done){
browserSync.reload();
done();
});
gulp.task('watch-xsd', ['xsd'], function(done){
browserSync.reload();
done();
});
gulp.task('serve', ['default'], function() {
browserSync.init({
server: {
baseDir: 'dist',
//directory: true
index: 'countries.xml'
}
});
gulp.watch('src/**/*.scss', ['watch-sass']);
gulp.watch('src/generateXml.js', ['watch-xml']);
gulp.watch('src/doc.dtd', ['watch-dtd']);
gulp.watch('src/doc.xsd', ['watch-xsd']);
});