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-slack

v0.1.1

Published

A friend mentioned something about this, and I thought it'd be a cool idea. I've written a few slack-bots in bash to do various things, like watch a folder and post the contents of new files (great for a headless server), or let me know when a deploy wa

Downloads

4

Readme

console.slack()

Overview

A friend mentioned something about this, and I thought it'd be a cool idea. I've written a few slack-bots in bash to do various things, like watch a folder and post the contents of new files (great for a headless server), or let me know when a deploy was complete. However, I now spend a lot of time in node.js, so a bot to do this without setting it up in bash would be super handy.

It's a pretty basic module. Not a great deal of functionality, but it should be customisable (with options) enough to do almost anything you require. If not, it's on github.

Please submit any issues here.

Setup

    var slack = require('console-slack');
    slack.options = options; // see below, or, set per-option.

Usage

There's not a lot to this one. This is it.

console.slack(message[, channel[, onSuccess]]);
  • message is the content to be posted to Slack.
  • channel is the Slack channel to be posted to. See below for defaults/options.
  • onSuccess is a function to be called once Slack has been successfully posted to.
    • It provides two parameters, the response from Slack, and the request status.

Options

The options shown below are the defaults (other than webhook). Webhook is the only required option, and can be set with slack.webhook if you don't want to pass in any other options.

slack.options = {
    webhook : "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
    username: "console.slack.bot", // the username you want to log with,
    emoji : ":nerd_face:", // set an emoji to be the bots profile picture,
    channel : "#general", 
}

There are a couple of options that have extended functionality.

  • slack.webhook can be set to 'test' to log to the console during development. If it's not set at all, calls to console.slack will fail. They have nowhere to go.

  • slack.channel can be set to true to send to the webhook's default channel. The channel can be set per-message, as well.

Example

var slack = require('console-slack');

slack.options = {
    webhook  : 'test', // don't want to make a post to slack
    emoji    : ':100:',
    username : 'cool-slack-bot'
}

console.slack('Hello, World!');
console.slack('Hello, Channel!', '#custom-channel');
console.slack('Hello, function!', '', function(resp, status){
    console.log('Response was: ' + resp);
    console.log('Status was: ' + status);
});