-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
101 lines (86 loc) · 2.95 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
var gulp = require('gulp'),
rename = require('gulp-rename'),
jsontransform = require('gulp-json-transform'),
concatjson = require('gulp-concat-json'),
clean = require('gulp-clean'),
run = require('run-sequence'),
exec = require('gulp-exec'),
bibtex2json = require('./citation/bibtex2json'),
fs = require('fs');
var paths = {
src: 'app',
dev: 'www',
json: 'comparison-elements-json/',
data: 'app/components/comparison/data/'
};
var files = {
data: [
'./app/components/comparison/data/*.json',
'./comparison-configuration/*',
'./citation/output/*',
'./favicon.ico'
],
markdown: [
'./comparison-elements/*.md'
],
json: [
'./comparison-elements-json/*.json'
]
}
var destfiles = {
index: './www'
}
// BUILD / UPDATE data files -------------------------------------<
gulp.task('build-data', function (callback) {
run('markdown', 'json', 'citation', callback);
})
gulp.task('update-data', function () {
gulp.watch(files.markdown, ['build-data']);
})
gulp.task('markdown', function(callback){
var options = {
continueOnError: false,
pipeStdout: true
}
return gulp.src(files.markdown)
.pipe(exec("./gradlew -q -b ./app/java/md-to-json/build.gradle run -PappArgs=\"[$/\n<%= file.contents.toString() %>\n/$, 1, true]\"", options))
.pipe(rename({extname: ".json"}))
.pipe(gulp.dest(paths.json));
});
gulp.task('json', function(){
return gulp.src(files.json)
.pipe(concatjson("data.json"))
.pipe(jsontransform(function(data){
return data;
}, 2))
.pipe(gulp.dest(paths.data))
})
gulp.task('citation', function(callback){
var fileContent = JSON.parse(fs.readFileSync("./citation/config.json", "utf8"));
bibtex2json.parse('./citation/' + fileContent.bibtex_file, 'utf8', './citation/' + fileContent.bibtex_style, './citation/output', callback);
})
// --------------------------------------------------------------->
// BUILD / UPDATE www folder -------------------------------------<
gulp.task('build-www', ['data'], function () {})
gulp.task('update-www', function () {
gulp.watch(files.data, ['data']);
})
gulp.task('data', function() {
return gulp.src(files.data, {base: '.'})
.pipe(gulp.dest(destfiles.index));
});
// --------------------------------------------------------------->
// DELETE www folder ---------------------------------------------<
gulp.task('delete-www', function() {
return gulp.src(paths.dev, {read: false})
.pipe(clean());
});
// --------------------------------------------------------------->
// DEFAULT and DEV tasks -----------------------------------------<
gulp.task('default', function(callback){
run('build-data', 'delete-www', 'build-www', callback);
});
gulp.task('dev', ['default'], function(callback) {
run('update-data','update-www', callback);
});
// --------------------------------------------------------------->