npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sh2png

v1.1.0

Published

Screenshot console output.

Downloads

2

Readme

Shell to PNG

Tools exist to screenshot websites, but why aren't there tools to screenshot console contents?

Add sample usage to your README as part of your build system, keep a tutorial's command line examples updated, or easily create a bug report without as much copy/paste.

And yes, the tool is compatible with all shells and many image formats, despite it's misleading name.

npm Build Status

Sample Output

Mocha's output

This image was created by passing the result of calling Mocha into sh2png.format.

See test-format-mocha-output.coffee for the test that produced the output above. See the results of testing sh2png for other examples.

Versioning

As per usual for Node applications, sh2png follows Semantic Versioning. See the CHANGELOG for information about each release.

For stability, minor versions are used if either

  • internal (private) methods are altered to have a different API
  • bugs are fixed that people might rely on

What does this mean? Lock down your minor number for sh2png in package.json if you:

  • Use images outputted sh2png in testing, where us fixing a pixel will break your test
  • Extend the sh2png class, and depend on the internal method signatures
  • Are building a core utility, which might have users in one of the above categories.

Otherwise, upgrading to the latest minor version or patch should be safe, as the public API should remain the same.

Either way, consider subscribing to an ATOM feed of our releases, so you can be notified about new versions.

Installation

Install via NPM.

Don't have NPM? Grab NodeJS or Node Version Manager.

npm install [--save-dev] sh2png

Console Usage

You can pipe text to sh2png on the command line. See sh2png --help for more information.

sh2png --help

(Created via sh2png --help | sh2png - > help.png)

Install the CLI utility globally across your entire computer via npm install -g sh2png, or access a locally installed binary via $(npm bin)/sh2png.

Node.js Usage

Formatting Strings

Got some text from the console? Call sh2png.format to turn a string of console text into an image. format returns a Promise.

Don't want to use Promises? Here's some standard NodeJS code.

sh2png = require("sh2png");
exec = require("child_process").exec;
env = process.env;
env.force_color_prompt = "yes";

exec("mocha", {env: env}, function (err, stdout, stderr) {
  // handle error
  sh2png
    .format(stdout)
    .then(function (img) {
      img.write(__dirname + "mocha_output.png", function(err) {
        // handle error
      });
    })
    .catch(function (err) {
      // handle error
    });
});

Want to use Promises? (Example in CoffeeScript)

sh2png = require "sh2png"
{exec} = require "child-process-promise"
env = process.env
env.force_color_prompt = "yes"

exec "mocha", {env}
  .then ({stdout}) ->
    sh2png.format stdout
  .then (img) ->
    img.writeAsync "#{__dirname}/mocha_output.png"
  .then ->
    # image written
  .catch (err) ->
    console.log err

See documentation for sh2png.format for more information.

Extending sh2png

If you want to extend sh2png, you're in luck. The source is object oriented, with documentation for each method. Simply override the methods you want to replace, and you're good to go!