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

@dashkite/genie

v0.8.4

Published

Task runner for CoffeeScript

Downloads

87

Readme

Genie

A CoffeeScript-based task runner. (And nothing else.)

See Masonry for functions that read, write, and process files.

Installation

npm i genie

Usage

npx genie [<task-name>...]

If no arguments are given, the defined tasks are listed.

Task definitions should be placed in the tasks directory.

Defining Tasks

Define tasks in your tasks/index.coffee file. Note that Genie will also check tasks/index.js for task definitions. We like CoffeeScript, so you'll see that in examples below, but as long as Node can require the files referenced in index, Genie can run the defined functions.

For example, here's a simple hello, world task.

import * as Genie from "@dashkite/genie"

Genie.define "hello-world", -> console.log "Hello, World"

Run the task like this:

npx genie hello-world

Dependent Tasks

You can define tasks that a given task depends on by simply listing them in an array or a whitespace-separated string.

Genie.define "build", "clean", ->
  # build task goes here

Parallel Tasks

You can append a ‘&’ to any task you define and it will run in parallel with the other tasks.

Genie.define "server", "html& css& js&", ->
  server "build", fallback: "index.html"

Before And After Tasks

You can add before and after tasks to other tasks as well, which is nice for augment pre-packaged tasks.

import * as Genie from "@dashkite/genie"

Genie.after "build", "images"

Event-Driven Tasks

You can define multiple task handlers via on in place of define:

import * as Genie from "@dashkite/genie"

Genie.on "hello-world", -> console.log "Hello, World"

The advantage of using on instead of define and before or after is that each handler is independent of the others. The disadvantage is that handlers run in the order they're declared, so you can't guarantee one handler will run before another. Using on provides an event-driven interface to tasks.

Important: Using define will overrite any handlers registered with on. You should avoid using define and on together for the same task name.

Parameterized Tasks

You can pass parameters to tasks in two ways. First, you can pass them via the environment.

targets='array' npx genie test

Second, you can define parameterized task names. Components of a task name are separated by :. If the task name is not found, the last component will be treated as an argument instead. This process continues until either a task name is found or there are no components remaining.

For example, suppose we have a task foo that takes a parameter. We can reference foo:bar and the string bar will be passed into the task.

So if our task definition is:

Genie.define "foo", (name) -> console.log "foo", name

and we run it as:

npx genie foo:bar

it will print foo bar.

Configuration

You may define a genie.yaml file in the directory from which you will run genie and that configuration will be available to tasks via the get function. This is useful for dynamically configuring pre-packaged tasks.

Presets

Development dependencies whose names (regardless of their scope) begin with genie- will be preloaded by Genie. Such modules are expected to export a (possibly asynchronous) task definition function taking the Genie instance that called them. They can then use this instance to define new tasks.

Preset loading may be surpressed for a given preset by using the -x option.

API

after

after task-name, task-to-run

Define a task to run after another task.

before

before task-name, task-to-run

Define a task to run before another task.

configure

configure configuration

Set the Genie configuration. The genie command reads this from the genie.yaml file.

define

define name, dependencies, fn

Define a task with the given name and dependencies using the given function.

get

get property → value

Read a property from the configuration.

list

list

List all the tasks that have been defined.

lookup

lookup name

Find a given task.

on

define name, dependencies, fn

Define a task handler with the given name and dependencies using the given function. Similar to define, but allows multiple handlers to run for the same task.

run

run name

Runs the given task name.