-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulp-build-codemirror.js
186 lines (160 loc) · 4.43 KB
/
gulp-build-codemirror.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import gulp from 'gulp';
import postcss from 'gulp-postcss';
import header from 'gulp-header';
import footer from 'gulp-footer';
import concat from 'gulp-concat';
import uglify from 'gulp-uglify-es';
const dir = 'node_modules/codemirror/';
// A List of each relevant JS file.
// See https://github.com/WordPress/better-code-editing/pull/92/files#diff-d624ea966e142693d2568ef0395f9aeb
let js = [
'lib/codemirror.js',
'keymap/emacs.js',
'keymap/sublime.js',
'keymap/vim.js',
'addon/hint/show-hint.js',
'addon/hint/anyword-hint.js',
'addon/hint/css-hint.js',
'addon/hint/html-hint.js',
'addon/hint/javascript-hint.js',
'addon/hint/sql-hint.js',
'addon/hint/xml-hint.js',
'addon/lint/lint.js',
'addon/lint/css-lint.js',
'addon/lint/html-lint.js',
'addon/lint/javascript-lint.js',
'addon/lint/json-lint.js',
'addon/lint/coffeescript-lint.js', // Added.
'addon/lint/yaml-lint.js', // Added.
'addon/comment/comment.js',
'addon/comment/continuecomment.js',
'addon/fold/xml-fold.js',
'addon/mode/overlay.js',
'addon/edit/closebrackets.js',
'addon/edit/closetag.js',
'addon/edit/continuelist.js',
'addon/edit/matchbrackets.js',
'addon/edit/matchtags.js',
'addon/edit/trailingspace.js',
'addon/dialog/dialog.js',
'addon/display/autorefresh.js',
'addon/display/fullscreen.js',
'addon/display/panel.js',
'addon/display/placeholder.js',
'addon/display/rulers.js',
'addon/fold/brace-fold.js',
'addon/fold/comment-fold.js',
'addon/fold/foldcode.js',
'addon/fold/foldgutter.js',
'addon/fold/indent-fold.js',
'addon/fold/markdown-fold.js',
'addon/merge/merge.js',
'addon/mode/loadmode.js',
'addon/mode/multiplex.js',
'addon/mode/simple.js',
// Should be included separately.
// 'addon/runmode/runmode-standalone.js',
'addon/runmode/runmode.js',
'addon/runmode/colorize.js',
'addon/scroll/annotatescrollbar.js',
'addon/scroll/scrollpastend.js',
'addon/scroll/simplescrollbars.js',
'addon/search/search.js',
'addon/search/jump-to-line.js',
'addon/search/match-highlighter.js',
'addon/search/matchesonscrollbar.js',
'addon/search/searchcursor.js',
// Shouldn't be included.
// 'addon/tern/worker.js',
// 'addon/tern/tern.js',
'addon/wrap/hardwrap.js',
'addon/selection/active-line.js',
'addon/selection/mark-selection.js',
'addon/selection/selection-pointer.js',
'mode/meta.js',
'mode/clike/clike.js',
'mode/css/css.js',
'mode/diff/diff.js',
'mode/htmlmixed/htmlmixed.js',
'mode/http/http.js',
'mode/javascript/javascript.js',
'mode/jsx/jsx.js',
'mode/markdown/markdown.js',
'mode/gfm/gfm.js',
'mode/nginx/nginx.js',
'mode/php/php.js',
'mode/sass/sass.js',
'mode/shell/shell.js',
'mode/sql/sql.js',
'mode/wast/wast.js',
'mode/xml/xml.js',
'mode/yaml/yaml.js'
];
// Prepend the source dir.
js = js.map( i => dir + i );
function copyCodeMirrorJS() {
var top = '(function () {',
bottom = [
'if ( ! window.wp ) {',
'window.wp = {};',
'}',
'window.wp.CodeMirror = this.CodeMirror;',
'})();'
].join( '\n' );
return gulp.src( js, { base: './node_modules' })
.pipe( concat( 'codemirror.min.js' ) )
.pipe( header( top ) )
.pipe( footer( bottom ) )
.pipe( uglify() )
.pipe( gulp.dest( 'dist/codemirror' ) );
}
function copyCodeMirrorModes() {
return gulp.src([
dir + 'mode/**/*.js'
], { base: './node_modules' })
.pipe( uglify() )
.pipe( gulp.dest( 'dist' ) );
}
function copyCodeMirrorThemes() {
return gulp.src([
dir + 'theme/**/*.css'
], { base: './node_modules' })
.pipe( gulp.dest( 'dist' ) );
}
function copyCodeMirrorStandalone() {
return gulp.src([
dir + 'addon/runmode/runmode-standalone.js'
])
.pipe( uglify() )
.pipe( gulp.dest( 'dist/codemirror' ) );
}
function copyCodeMirrorCSS() {
return gulp.src([
dir + 'lib/codemirror.css',
dir + 'mode/tiddlywiki/tiddlywiki.css',
dir + 'mode/tiki/tiki.css',
dir + 'addon/hint/show-hint.css',
dir + 'addon/lint/lint.css',
dir + 'addon/dialog/dialog.css',
dir + 'addon/display/fullscreen.css',
dir + 'addon/fold/foldgutter.css',
dir + 'addon/merge/merge.css',
dir + 'addon/scroll/simplescrollbars.css',
dir + 'addon/search/matchesonscrollbar.css',
dir + 'addon/tern/tern.css'
], { base: './node_modules' })
.pipe( concat( 'codemirror.min.css' ) )
.pipe( postcss() )
.pipe( gulp.dest( 'dist/codemirror' ) );
}
const copyCodeMirror = gulp.series(
copyCodeMirrorModes,
copyCodeMirrorJS,
copyCodeMirrorCSS,
copyCodeMirrorStandalone,
copyCodeMirrorThemes
);
export {
copyCodeMirror
};
export default copyCodeMirror;