Commit 5a197af6 authored by Benjamin Franzke's avatar Benjamin Franzke Committed by Susanne Moog
Browse files

[TASK] Convert ckeditor4 sources from CRLF to LF in grunt npmcopy

Git converts CRLF to LF when plaintext files are staged. The existing
copies of the rte_ckeditor Contrib/* sources have therefore already been
converted to LF by git [1]. Initially these files had been copied as CRLF
from the ckeditor4 sources in node_modules by grunt npmcopy.

Now, when `yarn build` is executed, the copy operation is performed again,
which means the files are reverted back to CRLF. Git therefore needs to
perform the CRLF to LF conversion again. (Which itself needs to be
triggered by the developer by staging the changed files)

We do now mimic git`s autocrlf behaviour and replace CRLF by LF in the
files copied from ckeditor Contrib/* folders to prevent the files
from clobbering the `git status` or `git diff` output.

By passing `encoding: null` to the grunt.file.copy options we ensure
that binary files will be copied as is.

Also configure *.svg files to be checked out as LF on all platforms
(namely windows) like we do for other plaintext files as well.
This ensures svg files do not show up (in windows) as changed because
their original from node_modules was stored as LF.
*.patch is added as patching jquery on windows would fail otherwise.

[1] https://git-scm.com/docs/gitattributes#_end_of_line_conversion

Resolves: #91374
Releases: master, 9.5
Change-Id: I2977a6d44f96f6593152bfe698ba5d35f32b131f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64481


Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
parent 9932767b
......@@ -19,6 +19,7 @@
*.scss text eol=lf
*.js text eol=lf
*.json text eol=lf
*.patch text eol=lf
*.php text eol=lf
*.rst text eol=lf
*.md text eol=lf
......@@ -29,5 +30,10 @@
*.xlf text eol=lf
*.sh text eol=lf
*.sql text eol=lf
*.svg text eol=lf
*.t3s text eol=lf
*.txt text eol=lf
/typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/plugins/codesnippet/lib/highlight/LICENSE text eol=lf
/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/cm/AUTHORS text eol=lf
/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/cm/LICENSE text eol=lf
/typo3/sysext/t3editor/Resources/Public/JavaScript/Contrib/cm/bin/source-highlight text eol=lf
......@@ -460,6 +460,12 @@ module.exports = function (grunt) {
},
ckeditor: {
options: {
copyOptions: {
// Using null encoding to allow passthrough of binary files in `process`
encoding: null,
// Convert CRLF to LF in plain text files to mimic git's autocrlf behaviour
process: (content, srcpath) => srcpath.match(/\.(css|js|txt|html|md)$/) ? content.toString('utf8').replace(/\r\n/g, '\n') : content
},
destPrefix: "<%= paths.ckeditor %>Public/JavaScript/Contrib"
},
files: {
......@@ -471,6 +477,12 @@ module.exports = function (grunt) {
},
ckeditor_externalplugins: {
options: {
copyOptions: {
// Using null encoding to allow passthrough of binary files in `process`
encoding: null,
// Convert CRLF to LF in plain text files to mimic git's autocrlf behaviour
process: (content, srcpath) => srcpath.match(/\.(css|js|txt|html|md)$/) ? content.toString('utf8').replace(/\r\n/g, '\n') : content
},
destPrefix: "<%= paths.ckeditor %>Public/JavaScript/Contrib/plugins"
},
files: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment