New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

lighthouse-provider

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lighthouse-provider

Provide the lighthouse launcher with commands in an easy fashion.

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

lighthouse-provider

Build Status

This module provides a way to easily define providers for menu entries to the lighthouse launcher. It depends on generators, so run node with the --harmony flag (or use io.js).

Quickstart

lighthouse.js:

#!/usr/bin/env node
var Lighthouse = require('lighthouse-provider');
var lighthouse = new Lighthouse();

lighthouse.attach(function *(input) {
	return {
		icon: '/some/path/to/icon.png',
		title: 'Execute [' + input + ']',
		action: input
	};
});

process.stdin.pipe(lighthouse).pipe(process.stdout);

You may now use this file as a cmd file for lighthouse.

API

Once you created a provider instance via

var lighthouse = new Lighthouse();

You can use it as a duplex stream:

process.stdin.pipe(lighthouse).pipe(process.stdout);

lighthouse.attach(identifier, handler)

This function allows you to provide a generator function for asynchronous data retrieval (will be run through co).

Identifier

The identifier parameter is optional and may be used, to filter for specific handlers.

So if your input to lighthouse looks like :someId actual input, only the handlers with the identifier someId will be called. You may use :: as an identifier to filter out only those handlers without an identifier.

Handler Function

The handler function will be called with whatever the user types into lighthouse (minus the identifier). It should return a co yieldable (so you may use a generator function here). As a second argument, it is provided a boolean signifying if the handlers flag was supplied. Your function may then do whatever it likes with it, retrieve data from the web, a file system or simply reformat the input etc.

Once done, simply return an object of the form:

{
	icon: '/some/path/to/icon.png',
	title: 'Execute [' + input + ']',
	action: input
}

The icon property may be omitted, but title and action are required. lighthouse-provider will then take care of escaping and formatting the output for you.

If you return anything but an object, your handler will not be output.

An array may be returned for multiple new entries.

lighthouse-provider-common

You may want to check out the lighthouse-provider-common module, for some useful providers.

FAQs

Package last updated on 25 Mar 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