-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
146 lines (136 loc) · 3.83 KB
/
gulpfile.ts
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const replace = require("gulp-replace");
const gulp = require("gulp");
const { exec } = require("child_process");
import fs from 'fs';
import { cv } from "./cv";
import { experience, skill, education, cvItem, personal } from "./generator";
let cvData: cv;
const cvJson = "./cv.json"
const outputDir = "output";
const resumeFinalDir = "../ethanmsmith.github.io/";
// Watch for file updates
gulp.task("watch", function () {
fs.readFile(cvJson, 'utf8', (err, data) => {
if (err) return;
cvData = JSON.parse(data);
(gulp.series("default"))();
});
gulp.watch(["*.tex","*.cls"]).on("change", (file: any) => {
(gulp.series("default"))();
});
gulp.watch("*.json").on("change", (file: any) => {
fs.readFile(cvJson, 'utf8', (err, data) => {
if (err) return;
cvData = JSON.parse(data);
(gulp.series("default"))();
});
});
});
gulp.task("writing, formatting, and moving cv.tex", function () {
return gulp
.src(["cv.tex"])
.pipe(replace("% BASICS", personal(cvData.basics)))
.pipe(replace("FOOTER", `{${cvData.basics.name}~~~·~~~Resume}`))
.pipe(gulp.dest(`${outputDir}/`));
});
gulp.task("writing and moving experiences.tex", () => {
return gulp
.src(["cv/experience.tex"])
.pipe(
replace(
"EXPERIENCES",
cvData.work
.map((workItem) =>
experience(
workItem.position,
workItem.company,
workItem.location,
workItem.startDate,
workItem.endDate,
workItem.summary,
workItem.highlights
? workItem.highlights.map(
(highlight): cvItem => ({ text: highlight })
)
: []
)
)
.join("\n")
)
)
.pipe(gulp.dest(`${outputDir}/cv/`));
});
gulp.task("writing and moving education.tex", () =>
gulp
.src(["cv/education.tex"])
.pipe(
replace(
"EDUCATION",
education(
cvData.education[0].area,
cvData.education[0].institution,
cvData.education[0].location,
cvData.education[0].startDate,
cvData.education[0].endDate,
cvData.education[0].courses
)
)
)
.pipe(gulp.dest(`${outputDir}/cv/`))
);
gulp.task("writing and moving skills.tex", () =>
gulp
.src(["cv/skills.tex"])
.pipe(
replace(
"SKILLS",
cvData.skills
.map((skillItem) => skill(skillItem.name, skillItem.keywords))
.join("\n")
)
)
.pipe(gulp.dest(`${outputDir}/cv/`))
);
gulp.task("writing and moving summary.tex", () =>
gulp
.src(["cv/summary.tex"])
.pipe(replace("SUMMPARAGRAPH", cvData.basics.summary))
.pipe(gulp.dest(`${outputDir}/cv/`))
);
gulp.task("execute xelatex", (cb: any) => {
// gulp.src(['awesome-cv.cls']).pipe(gulp.dest(`${outputDir}/`));
// gulp.src(['fontawesome.sty']).pipe(gulp.dest(`${outputDir}/`));
exec(
`cp -f awesome-cv.cls ${outputDir}/;cp -f fontawesome.sty ${outputDir}/;cp -R fonts ${outputDir}/fonts;`,
(err: any, stdout: any, stderr: any) => {
if (err) {
console.log("ERROR: Some shit happened, not sure what. Good luck.");
} else {
exec(
`xelatex cv.tex;`,
{ cwd: outputDir },
(err: any, stdout: any, stderr: any) => {
if (err) {
console.log("ERROR:");
} else {
gulp.src(`${outputDir}/cv.pdf`).pipe(gulp.dest(resumeFinalDir));
cb();
}
cb();
}
);
}
}
);
});
gulp.task(
"default",
gulp.series(
"writing, formatting, and moving cv.tex",
"writing and moving summary.tex",
"writing and moving experiences.tex",
"writing and moving education.tex",
"writing and moving skills.tex",
"execute xelatex"
)
);