Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active May 14, 2016 19:38
Show Gist options
  • Save toolmantim/48ca212160881f7254b7 to your computer and use it in GitHub Desktop.
Save toolmantim/48ca212160881f7254b7 to your computer and use it in GitHub Desktop.
Node functions for embedding images in your build output using iTerm or Buildkite
var fs = require('fs');
function artifactOutput(imagePath) {
return '\033]1338;url=artifact://' + imagePath + ';alt=' + imagePath + '\07\n';
}
function base64Output(imagePath) {
var encodedImage = fs.readFileSync(imagePath, {encoding: 'base64'});
return '\033]1337;File=name=' + imagePath + ';inline=1:' + encodedImage + '\07\n';
}
function inlineImage(imagePath) {
if (process.env.CI)
return artifactOutput(imagePath);
else
return base64Output(imagePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment