-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
56 lines (44 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
55
56
import gulp from "gulp";
import gulpMergeJson from 'gulp-merge-json';
const { src, dest, watch } = gulp;
function joinJSONs(extension) {
const gulpMergeJsonConfig = {
fileName: `snippets.${extension}.code-snippets`,
}
return src([`src/snippets/${extension}/*.json`])
.pipe(gulpMergeJson(gulpMergeJsonConfig))
.pipe(dest("dist/snippets"));
}
function joinSchema() {
const gulpMergeJsonConfig = {
fileName: `schema.json`,
}
return src([`src/schema/*.json`])
.pipe(gulpMergeJson(gulpMergeJsonConfig))
.pipe(dest("dist/schema"));
}
function time () {
const data = new Date();
const hora = data.getHours();
const minuto = data.getMinutes();
const segundo = data.getSeconds();
const horaFormatada = hora < 10 ? `0${hora}` : hora;
const minutoFormatado = minuto < 10 ? `0${minuto}` : minuto;
const segundoFormatado = segundo < 10 ? `0${segundo}` : segundo;
return `[${horaFormatada}:${minutoFormatado}:${segundoFormatado}]`;
}
async function dev () {
await joinJSONs('json');
console.log(time() + ' JSON snippets generated');
await joinJSONs('css');
console.log(time() + ' CSS snippets generated');
await joinSchema();
console.log(time() + ' JSON schema generated');
}
const watchOptions = {
delay: 150,
ignoreInitial: false,
}
const _dev = dev;
export { _dev as dev };
watch('src/**/*.json',watchOptions, dev);