Created
September 30, 2019 18:02
-
-
Save mrtnzlml/6d6749f16a530d07e7ef18be6595c70e to your computer and use it in GitHub Desktop.
Downloading Slack emojis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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