forked from Laboratoria/curriculum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulp-utils.js
41 lines (35 loc) · 1.06 KB
/
gulp-utils.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
const shell = require('gulp-shell');
module.exports = (gulp, topic, lessons) => {
const sh = {
test: lessons.reduce((cmd, l) => `${cmd} && node ${l}/index.js`, 'true'),
/*
- elimina todo los `md` que hayan de antes
- regenera los `mds`
- quita el timestamp que genera `jdi` al final del md
*/
gen: lessons.reduce((cmd, l) => `
${cmd} &&
rm ${l}/README.md || true &&
npx jdi ${l}/index.js &&
head -n -4 ${l}/index.js.md > ${l}/README.md && rm ${l}/index.js.md`,
'true'),
eslint: `
cd ../../../ &&
npx eslint topics/javascript/${topic}
`,
mdlint: `
cd ../../../ &&
npx mdlint topics/javascript/${topic}
`,
};
Object.keys(sh).forEach((task) => {
gulp.task(task, shell.task(sh[task]));
});
gulp.task('lint', gulp.parallel('eslint', 'mdlint'));
const tasks = gulp.series(['test', 'gen', 'lint']);
const genTasks = gulp.series(['gen', 'test']);
gulp.task('watch', gulp.series(genTasks, () => {
gulp.watch('**/*.js', genTasks);
}));
gulp.task('default', tasks);
};