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

console-formatter

v1.0.3

Published

NPM Library that pretty-prints testing results to the console

Downloads

1

Readme

console-formatter

console-fomratter is an NPM Library that pretty-prints testing results to the console This is a NodeJS version of the Bash Check Scirpt Formatter. There is also a Python3 Version. Eventually, a Powershell Version will be published.

Installation

To install the package locally, run the following. To install globally, add the -g flag

npm i console-formatter

Once installed, the module is available for import. There are two functions include in the package

  • printTitle()
  • printMsg()

Import the modules using require.

const printTitle = require('console-formatter').printTitle;
const printMsg = require('console-formatter').printMsg;

Usage

printTitle

To print an underlined title to the console, call it the printTitle function with a string

printTitle('This is a title')

printMsg

The printMsg function requires both a string and a integer. The integer represents an exit code. Number 0-4 are supported. Refer to the table below for each number's associated response code.

Integer | Response --- | --- 0 | SUCCESS 1 | FAIL 2 | WARNING 3 | INFO

To call the printMsg function, run the following.

printMsg('Message to be displayed', 3)

Examples

The script below uses the npm package systemd-status. Thanks ZimGill. The script checks the status of a couple of systemd daemons and calls the printMsg function accordingly.

const systemdStatus = require('systemd-status');
const printTitle = require('console-formatter').printTitle;
const printMsg = require('console-formatter').printMsg;

printTitle('Test Systemd Service Status');

const currentStatus = systemdStatus(['httpd', 'firewalld' ]);

for (i=0; i<currentStatus.length; i++) {
        serviceName = currentStatus[i].name;
        serviceState = currentStatus[i].state;

        if (serviceState == 'running') {
                var rc = 0;
        } else if (serviceState = 'dead') {
                var rc = 2;
        }

        printMsg("Check " + serviceName + " is running", rc );
}

console.log('\n');

Results

Alt text