-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.js
44 lines (37 loc) · 1.21 KB
/
index.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
if (process.argv.length === 2) {
console.error('Pass in a Slack OAuth token as argument 1');
process.exit(1);
}
const emojme = require('emojme');
const token = process.argv[2];
const fs = require('fs');
const downloadOptions = {
save: false,
bustCache: true,
output: false,
};
emojme.download('zatech', token, downloadOptions).then((res) => {
const remoteEmojis = res.zatech.emojiList.map(e => e.name);
const localEmojis = fs.readdirSync('./emojis/');
const missing = localEmojis.filter((fn) => {
return fn.substr(0, 1) !== '.';
}).filter((fn) => {
const emojiName = removeExt(fn);
return remoteEmojis.indexOf(emojiName) === -1;
});
const addOptions = {
src: missing.map(e => './emojis/' + e), // File paths
name: missing.map(e => removeExt(e)), // Emoji names
bustCache: false,
avoidCollisions: false,
output: false,
};
emojme.add('zatech', token, addOptions).then((res) => {
console.log('Added Emoji:', res.zatech.emojiList);
}).catch(error => {
console.error('Failed to Add', addOptions, error);
});
});
function removeExt(string) {
return string.substr(0, string.indexOf('.'));
}