Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cache.forEach(({ diffRatio, diffPixelCount, diffOutputPath }) => {
console.log(
`\n - ${diffOutputPath}\n Screenshot was ${diffRatio *
100}% different from saved snapshot with ${diffPixelCount} different pixels.\n`
);
termImage(diffOutputPath, { fallback });
});
}
emotes.forEach(emote => {
const { id, code } = emote
const img = termImg.string(path.join(IMAGES_DIR, `${id}.png`))
map[code] = img
})
})
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
if(cheerEmoteList.includes(type)) {
const tier = getCheerTier(type, amount, cheerEmotes);
if(loadImages) {
const emote = await getCheerEmote(type, tier);
return prefix + termImg.string(emote, {
fallback: () => cheers.formatCheer(amount, tier.color)
}) + chalk.bold.hex(tier.color)(amount) + postfix;
}
return prefix + cheers.formatCheer(amount, tier.color) + postfix;
}
return match;
});
}
exports.buffer = async buffer => {
return termImg.string(buffer, {
width: '100%',
height: '100%',
fallback: () => render(buffer)
});
};
const frags = await Promise.all(msg.message.fragments.map(async (f) => {
if(f.emoticon && loadImages) {
const emote = await getEmoticon(f.emoticon.emoticon_id);
return termImg.string(emote, {
fallback: () => f.text
});
}
else if(msg.message.bits_spent) {
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
if(cheerEmoteList.includes(type)) {
const tier = getCheerTier(type, amount, cheerEmotes);
if(loadImages) {
const emote = await getCheerEmote(type, tier);
return prefix + termImg.string(emote, {
fallback: () => cheers.formatCheer(amount, tier.color)
}) + chalk.bold.hex(tier.color)(amount) + postfix;
}
return prefix + cheers.formatCheer(amount, tier.color) + postfix;
}
return match;
public async saveScreenshot(fn: (path: string) => Promise): Promise {
const path = this.workRoot.join('screenshots', `${cuid()}.jpg`)
debugScreenshot(`Saving screenshot to: ${path}`)
if (await fn(path)) {
this.screenshots.push(path)
debugScreenshot(`Saved screenshot to: ${path}`)
termImg(path, {
width: '40%',
fallback: () => {
return `Screenshot path: ${path}`
},
})
}
}
}