Provide the lighthouse launcher with commands in an easy fashion.
Last updated 3 years ago by paulavery .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball
$ cnpm install lighthouse-provider 
SYNC missed versions from official npm registry.


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).



#!/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


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


Once you created a provider instance via

var lighthouse = new Lighthouse();

You can use it as a duplex stream:


lighthouse.attach(identifier, handler)

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


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.


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

Maintainers (1)
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 0
Last Month 15
Dependencies (1)
  • co ^4.4.0
Dev Dependencies (6)
Dependents (2)

Copyright 2014 - 2017 © |