Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

health

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

health - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/formatters/cli.js

6

CHANGELOG.md

@@ -1,2 +0,6 @@

### 0.0.4-pre
### 0.0.5-pre
* Add cli formatter
* Fix CLI exit code to be the number of non-ok status
### 0.0.4
* Add CLI with init and check commands

@@ -3,0 +7,0 @@

2

conf/commands.json

@@ -10,3 +10,3 @@ {

{ "arg": "-s, --setup-file <setupFile>", "desc": "Setup file, default: health.json" },
{ "arg": "-f, --formatter <formatter>", "desc": "Result formatter: html, text, or xml, default: text" }
{ "arg": "-f, --formatter <formatter>", "desc": "Result formatter: cli, html, text, or xml, default: cli" }
]

@@ -13,0 +13,0 @@ }

@@ -1,3 +0,5 @@

var bag = require('bagofholding'),
Health = require('./health');
var _ = require('underscore'),
bag = require('bagofholding'),
Health = require('./health'),
util = require('util');

@@ -9,15 +11,26 @@ function _init() {

function _check(args) {
var setup = JSON.parse(bag.cli.lookupFile(args.setupFile || 'health.json')),
opts = {
setup: setup,
formatter: args.formatter || 'text'
};
new Health(opts).check(bag.cli.exitCb(null, function (result) {
if (Array.isArray(result)) {
result.forEach(function (line) {
function log(result) {
var formatted = require('./formatters/' + (args.formatter || 'cli')).format(result);
if (Array.isArray(formatted)) {
formatted.forEach(function (line) {
console.log(line);
});
} else {
console.log(result);
console.log(formatted);
}
}
function exit(result) {
var numNonOk = _.countBy(result, function (item) {
return (item.status === 'ok') ? 'ok' : 'non-ok';
})['non-ok'];
process.exit(numNonOk);
}
var setup = JSON.parse(bag.cli.lookupFile(args.setupFile || 'health.json'));
new Health({ setup: setup }).check(bag.cli.exitCb(null, function (result) {
console.dir(result);
log(result);
exit(result);
}));

@@ -24,0 +37,0 @@ }

@@ -9,3 +9,3 @@ {

],
"version": "0.0.4",
"version": "0.0.5",
"homepage": "http://github.com/cliffano/health",

@@ -35,2 +35,3 @@ "author": "Cliffano Subagio <blah@cliffano.com> (http://blog.cliffano.com)",

"bagofholding": "0.1.6",
"colors": "0.6.0-1",
"fs.extra": "1.2.0",

@@ -37,0 +38,0 @@ "memory-cache": "0.0.5",

@@ -42,2 +42,6 @@ Health [![Build Status](https://secure.travis-ci.org/cliffano/health.png?branch=master)](http://travis-ci.org/cliffano/health) [![Dependencies Status](https://david-dm.org/cliffano/health.png)](http://david-dm.org/cliffano/health)

From command-line:
health -f html -s health.json check
Configuration

@@ -44,0 +48,0 @@ -------------

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc