forked from metowolf/vCards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (74 loc) · 2 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
import fs from 'fs'
import path from 'path'
import { deleteAsync } from 'del'
import through2 from 'through2'
import gulp from 'gulp'
import zip from 'gulp-zip'
import concat from 'gulp-concat'
import rename from 'gulp-rename'
import concatFolders from 'gulp-concat-folders'
import plugin_vcard from './plugins/vcard.js'
import plugin_vcard_ext from './plugins/vcard-ext.js'
const generator = () => {
return gulp.src('data/*/*.yaml')
.pipe(through2.obj(plugin_vcard))
.pipe(rename({ extname: '.vcf' }))
.pipe(gulp.dest('./temp'))
}
const generator_ext = () => {
return gulp.src('data/*/*.yaml')
.pipe(through2.obj(plugin_vcard_ext))
.pipe(rename({ extname: '.vcf' }))
.pipe(gulp.dest('./temp'))
}
const archive = () => {
return gulp.src('temp/**')
.pipe(zip('archive.zip'))
.pipe(gulp.dest('./public'))
}
const combine = () => {
return gulp.src('temp/*/*.vcf')
.pipe(concatFolders('汇总'))
.pipe(rename({ extname: '.all.vcf' }))
.pipe(gulp.dest('./temp'))
}
const allinone = () => {
return gulp.src('temp/汇总/*.all.vcf')
.pipe(concat('全部.vcf'))
.pipe(gulp.dest('./temp/汇总'))
}
const clean = () => {
return deleteAsync([
'public',
'temp'
])
}
const createRadicale = () => {
let folders = fs.readdirSync('temp')
.filter(function(f) {
return fs.statSync(path.join('temp', f)).isDirectory();
})
folders.map(function(folder){
fs.writeFileSync(path.join('temp', folder, '/.Radicale.props'), '{"D:displayname": "' + folder + '", "tag": "VADDRESSBOOK"}')
})
return gulp.src('temp/**', {})
}
const cleanRadicale = () => {
return deleteAsync([
'radicale'
], {force: true})
}
const distRadicale = () => {
return gulp.src('temp/**', {dot: true})
.pipe(gulp.dest('./radicale'))
}
const build = gulp.series(clean, generator, combine, allinone, archive)
const radicale = gulp.series(clean, generator_ext, createRadicale, cleanRadicale, distRadicale)
export {
generator,
combine,
allinone,
archive,
build,
radicale
}