forked from kodefox/react-native-parse-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
120 lines (99 loc) · 3.5 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
var fork = require('child_process').fork,
gulp = require('gulp'),
eslint = require('gulp-eslint'),
mocha = require('gulp-mocha'),
install = require('gulp-install'),
benchmark = require('gulp-benchmark'),
rename = require('gulp-rename'),
download = require('gulp-download'),
through = require('through2'),
concat = require('gulp-concat'),
jsdoc = require('gulp-jsdoc-to-markdown'),
insert = require('gulp-insert'),
generateNamedEntityData = require('./scripts/generate_named_entity_data'),
generateParserFeedbackTest = require('./scripts/generate_parser_feedback_test');
// Docs
gulp.task('update-api-reference', function () {
return gulp
.src('lib/**/*.js')
.pipe(concat('05_api_reference.md'))
.pipe(jsdoc())
.pipe(insert.prepend('# API Reference\n'))
.pipe(gulp.dest('docs'));
});
gulp.task('docs', ['update-api-reference'], function () {
return gulp
.src('docs/*.md')
.pipe(concat('index.md'))
.pipe(gulp.dest('docs/build'));
});
// Benchmarks
gulp.task('install-upstream-parse5', function () {
return gulp
.src('test/benchmark/package.json')
.pipe(install());
});
gulp.task('benchmark', ['install-upstream-parse5'], function () {
return gulp
.src('test/benchmark/*.js', {read: false})
.pipe(benchmark({
failOnError: true,
reporters: benchmark.reporters.etalon('Upstream')
}));
});
gulp.task('install-memory-benchmark-dependencies', function () {
return gulp
.src('test/memory_benchmark/package.json')
.pipe(install());
});
gulp.task('sax-parser-memory-benchmark', ['install-memory-benchmark-dependencies'], function (done) {
fork('./test/memory_benchmark/sax_parser').once('close', done);
});
gulp.task('named-entity-data-memory-benchmark', function (done) {
fork('./test/memory_benchmark/named_entity_data').once('close', done);
});
// Test
gulp.task('lint', function () {
return gulp
.src([
'lib/**/*.js',
'test/**/*.js',
'scripts/**/*.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test', ['lint'], function () {
return gulp
.src('test/fixtures/*_test.js')
.pipe(mocha({
ui: 'exports',
reporter: 'progress',
timeout: typeof v8debug === 'undefined' ? 20000 : Infinity // NOTE: disable timeouts in debug
}));
});
// Scripts
gulp.task('update-feedback-tests', function () {
return gulp
.src(['test/data/tree_construction/*.dat', 'test/data/tree_construction_regression/*.dat'])
.pipe(through.obj(function (file, encoding, callback) {
var test = generateParserFeedbackTest(file.contents.toString());
file.contents = new Buffer(test);
callback(null, file);
}))
.pipe(rename({extname: '.test'}))
.pipe(gulp.dest('test/data/parser_feedback'));
});
gulp.task('update-named-entities-data', function () {
return download('https://html.spec.whatwg.org/multipage/entities.json')
.pipe(through.obj(function (file, encoding, callback) {
var entitiesData = JSON.parse(file.contents.toString());
file.contents = new Buffer(generateNamedEntityData(entitiesData));
callback(null, file);
}))
.pipe(rename('named_entity_data.js'))
.pipe(gulp.dest('lib/tokenizer'));
});