Skip to content

Instantly share code, notes, and snippets.

@mrtnzlml
Created September 30, 2019 18:02
Show Gist options
  • Save mrtnzlml/6d6749f16a530d07e7ef18be6595c70e to your computer and use it in GitHub Desktop.
Save mrtnzlml/6d6749f16a530d07e7ef18be6595c70e to your computer and use it in GitHub Desktop.
Downloading Slack emojis
import fs from 'fs';
import path from 'path';
import fetch from '@kiwicom/fetch';
// See: https://gist.github.com/lmarkus/8722f56baf8c47045621
import { emoji } from './emoji.json';
(async function() {
for (const [name, link] of Object.entries(emoji)) {
const downloadLink = link;
if (link.startsWith('alias:')) {
continue;
}
const result = await fetch(downloadLink);
const match = downloadLink.match(/.+\.(?<extension>[a-z]+)$/i);
const iconPath = path.join(__dirname, 'output', `${name}.${match.groups.extension}`);
const fileStream = fs.createWriteStream(iconPath);
result.body.pipe(fileStream);
result.body.on('finish', () => {
console.warn('Saved %s', iconPath);
});
result.body.on('error', err => {
throw err;
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment