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

sushi

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sushi

Express for CLI apps

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-52.69%
Maintainers
1
Weekly downloads
 
Created
Source

sushi Circle CI

Express for CLI apps.

Installation

$ npm install sushi --save

Usage

myapp.js:

var sushi = require('sushi');

var app = sushi();

app.on('start', function () {
  console.log('start command');
});

app.on('stop', function () {
  console.log('stop command');
});

app.on('index', function () {
  console.log('index command');
});

app.run();
$ node myapp.js start
start command

$ node myapp.js stop
stop command

$ node myapp.js
index command

Arguments

Program arguments are parsed using minimist. Each command gets parsed arguments using minimist in a first argument:

app.on('start', function (args) {
  var name = args._[0];

  var delay = args.delay;

  console.log('start', name, 'with', delay, 'delay');
});
$ node myapp.js start my-process --delay 500ms
start my-process with 500ms delay

Index command

Index command can be assigned using .on('index', fn). It will be executed, when no other commands match.

app.on('index', function (args) {
  console.log('index command');
});
$ node myapp.js
index command

Middleware

Middleware is a function, that modifies the context or arguments before target command is executed.

app.use(function (args, context, next) {
  context.ok = true;

  // call `next()` when done
  next();
});

app.on('start', function (args, context) {
  context.ok === true; // true

  console.log('start command');
});

Middleware can also abort command:

app.use(function (args, context, next) {
  var err = new Error('Fatal error');

  next(err);
});

app.on('start', function (args, context) {
  // won't be executed
});

app.on('error', function (err) {
  // err is the Error instance from middleware

  err.message === 'Fatal error'; // true
});

Tests

Circle CI

$ make test

License

MIT © Vadym Demedes

Keywords

FAQs

Package last updated on 13 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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