73bcce88
luigser
COMPONENTS
|
1
2
3
4
5
|
var gulp = require('gulp'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
header = require('gulp-header'),
concat = require('gulp-concat'),
|
eb240478
Luigi Serra
public room cards...
|
6
7
|
replace = require('gulp-replace'),
fs = require('fs'),
|
73bcce88
luigser
COMPONENTS
|
8
9
|
paths = {
|
eb240478
Luigi Serra
public room cards...
|
10
|
componentsFile: 'components.js',
|
73bcce88
luigser
COMPONENTS
|
11
12
13
14
15
16
17
18
19
|
components: ['components/**/*.js', '!components/**/*.min.js'],
main: [
'components/prism-core.js',
'components/prism-markup.js',
'components/prism-css.js',
'components/prism-clike.js',
'components/prism-javascript.js',
'plugins/file-highlight/prism-file-highlight.js'
],
|
eb240478
Luigi Serra
public room cards...
|
20
21
|
plugins: ['plugins/**/*.js', '!plugins/**/*.min.js'],
showLanguagePlugin: 'plugins/show-language/prism-show-language.js',
|
f748e9cf
Luigi Serra
new controllet an...
|
22
23
|
autoloaderPlugin: 'plugins/autoloader/prism-autoloader.js',
changelog: 'CHANGELOG.md'
|
73bcce88
luigser
COMPONENTS
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
};
gulp.task('components', function() {
return gulp.src(paths.components)
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('components'));
});
gulp.task('build', function() {
return gulp.src(paths.main)
.pipe(header('\n/* **********************************************\n' +
' Begin <%= file.relative %>\n' +
'********************************************** */\n\n'))
.pipe(concat('prism.js'))
.pipe(gulp.dest('./'));
});
|
eb240478
Luigi Serra
public room cards...
|
42
|
gulp.task('plugins', ['languages-plugins'], function() {
|
73bcce88
luigser
COMPONENTS
|
43
44
45
46
47
48
49
50
51
52
53
|
return gulp.src(paths.plugins)
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('plugins'));
});
gulp.task('watch', function() {
gulp.watch(paths.components, ['components', 'build']);
gulp.watch(paths.plugins, ['plugins', 'build']);
});
|
eb240478
Luigi Serra
public room cards...
|
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
|
gulp.task('languages-plugins', function (cb) {
fs.readFile(paths.componentsFile, {
encoding: 'utf-8'
}, function (err, data) {
if (!err) {
data = data.replace(/^var\s+components\s*=\s*|;\s*$/g, '');
try {
data = JSON.parse(data);
var languagesMap = {};
var dependenciesMap = {};
for (var p in data.languages) {
if (p !== 'meta') {
var title = data.languages[p].displayTitle || data.languages[p].title;
var ucfirst = p.substring(0, 1).toUpperCase() + p.substring(1);
if (title !== ucfirst) {
languagesMap[p] = title;
}
if(data.languages[p].require) {
dependenciesMap[p] = data.languages[p].require;
}
}
}
var jsonLanguagesMap = JSON.stringify(languagesMap);
var jsonDependenciesMap = JSON.stringify(dependenciesMap);
var tasks = [
{plugin: paths.showLanguagePlugin, map: jsonLanguagesMap},
{plugin: paths.autoloaderPlugin, map: jsonDependenciesMap}
];
var cpt = 0;
var l = tasks.length;
var done = function() {
cpt++;
if(cpt === l) {
cb && cb();
}
};
tasks.forEach(function(task) {
var stream = gulp.src(task.plugin)
.pipe(replace(
/\/\*languages_placeholder\[\*\/[\s\S]*?\/\*\]\*\//,
'/*languages_placeholder[*/' + task.map + '/*]*/'
))
.pipe(gulp.dest(task.plugin.substring(0, task.plugin.lastIndexOf('/'))));
stream.on('error', done);
stream.on('end', done);
});
} catch (e) {
cb(e);
}
} else {
cb(err);
}
});
});
|
f748e9cf
Luigi Serra
new controllet an...
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
gulp.task('changelog', function (cb) {
return gulp.src(paths.changelog)
.pipe(replace(
/#(\d+)(?![\d\]])/g,
'[#$1](https://github.com/PrismJS/prism/issues/$1)'
))
.pipe(replace(
/\[[\da-f]+(?:, *[\da-f]+)*\]/g,
function (match) {
return match.replace(/([\da-f]{7})[\da-f]*/g, '[`$1`](https://github.com/PrismJS/prism/commit/$1)');
}
))
.pipe(gulp.dest('.'));
});
|
73bcce88
luigser
COMPONENTS
|
132
|
gulp.task('default', ['components', 'plugins', 'build']);
|