spiegel-keyman/resources/tools/strip-emoji/index.js
Marc Durdin db514e0dc5 fix(common): update emoji stripping for Unicode 15.1
Fixes #11220.

Replaces the sed script for matching emoji in ios prepRelease with a
tiny node project that uses emoji-regex package, to reduce future
maintenance.

Also strips lingering emoji and :xxx: emoji shortcut strings from
HISTORY.md. Note that :xxx: are not stripped programatically at this
time.
2024-04-18 09:05:30 +07:00

18 lines
No EOL
461 B
JavaScript

const emojiRegex = require('emoji-regex');
process.stdin.setEncoding('utf-8');
// We will concatenate all strings and assume we are not processing a huge file,
// so we don't break in the middle of a UTF-8 sequence or split emoji sequences
// in half.
let stream = '';
process.stdin.on('readable', () => {
const data = process.stdin.read();
if(data) {
stream += data;
} else {
process.stdout.write(stream.replaceAll(emojiRegex(), ''));
}
});