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

kool-shell

v2.1.0

Published

A minimal module to deal with the shell

Downloads

32

Readme

kool-shell

:microphone::tv::notes: A minimal module to deal with shell

Build Status Build Status

Spinner

Features

  • 1 dependency (support-color)
  • Native promises from Nodejs
  • Shell commands with silent & inherited stdio
  • Ansi Colors + Auto-detects color support
  • Log methods with 4 log levels
  • User input with hidden input option
  • List input with multiple or single choice
  • Awesome emoji-based spinner
  • Progressbar
  • Create and add your own kool-shell plugins easily
  • Cool emojis!

Requirements

  • Node > 8
  • npm > 5
  • ANSI/VT100 compatible terminal

Installation

npm install --save kool-shell

Usage

Create a new kool-shell instance

const sh = require('kool-shell')
sh.warn(sh.colors.gray('Display a gray warning'))

// You can also use object destructuring
const { warn, colors } = require('kool-shell')
warn(colors.gray('Display a gray warning'))

Namespacing

It can be useful to not share kool-shell configuration and state when dealing with multiple modules. You can specify a namespace using the kool-shell/namespaced module.

const sh1 = require('kool-shell/namespaced')('MyModule')
sh1.setLogOptions(globalPrefix: '[MyModule] ')
sh1.log('Customized log for the MyModule namespace')

const sh2 = require('kool-shell')
sh2.log('This log will not have the [MyModule] prefix')

Kool-shell features

All features are basically native plugins, always available in kool-shell. See the Plugins section below to learn how to create & add your own plugins.

  • Log - Log functions
  • Colors - Add colors to your log messages
  • Progressbar - Display a progressbar
  • Spinner - Display a spinner
  • Exec - Execute a promised shell command
  • Input - User prompt with hidden input option
  • Select - Select/Radio input
  • Cleanup - Do some actions before exiting your app
  • Exit - Simple alias of process.exit(code)

Plugins

Add a plugin

Add a plugin with sh.use(plugin, [options]). You can specify options for your plugin.

const koolPlugin = require('kool-shell-plugin')
sh.use(koolPlugin, { colors: false })

Create a plugin

Plugin template
module.exports = myPlugin (sh, opts = {}) {
  return {
    sayHello () {
      // kool-shell native features are always available from the sh object.
      // for instance, you can easily use colors using sh.colors method
      opts.gray
        ? console.log('hello.')
        : console.log(sh.colors.gray('hello'))
    }
  }
}

Two arguments will be passed when your plugin is used through sh.use():

  • sh is the kool-shell instance used
  • opts is the options object passed trough sh.use(plugin, options)

Your plugin need to be a function that return an object. When your plugin is used, the returned object will be merged into the api object of the kool-shell instance.

:warning: Method/Property will be overiden if a new one has the same name. Namespace your plugin api if you use common method names

To do

  • Test all native features

License

MIT.