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 🙏

© 2026 – Pkg Stats / Ryan Hefner

task-env

v2.14.7

Published

A framework for building reusable JS tasks

Readme

Task Env

A framework for building reusable JS tasks.

| Feature | Built With | | ------------------------------------------- | -------------------------------------------------------------- | | Parse CLI arguments | mri | | Interact with the CLI | Inquirer.js | | Execute commands | commandland | | JSON and text store | dot-store |

Install

npm install --save-dev task-env

Create an executable

touch run
chmod +x run

Write some code

#!/usr/bin/env node

require("task-env")({
  args: process.argv.slice(2),
  tasks: [
    {
      sayHello: ({ hello }) => {
        console.log(">", hello)
      },
    },
  ],
})

Run your task

./run sayHello --hello=hi
> hi

Package tasks

Export task:

export function sayHello({ hello }) {
  console.log(hello)
}

Require task:

#!/usr/bin/env node

require("task-env")({
  args: process.argv.slice(2),
  tasks: [require("./say-hello")],
})

Interact

export async function happy({ ask }) {
  let { happy } = await ask([
    {
      type: "confirm",
      name: "happy",
      message: "Are you happy?",
    },
  ])
}

See the Inquirer.js prompt docs for available options.

Call other tasks

export function sayHello({ tasks }) {
  tasks.say({ text: "hello" })
}

export function say({ text }) {
  console.log(">", text)
}

Calling through tasks binds the CLI arguments and helper functions, as if the task were called via CLI.

Execute commands

export async function ls({ run }) {
  await run("ls", ["/"])
}

See the commandland docs for available options.

JSON and text store

Task env uses dot-store to provide an immutable store with atomic filesystem persistence.

Create a directory with some JSON files:

{
  "users": {
    "bob": {
      "key": "~/.ssh/bob_rsa"
    }
  }
}

The stores option allows you to define multiple named stores:

#!/usr/bin/env node

require("task-env")({
  args: process.argv.slice(2),
  stores: {
    config: {
      pattern: "**/*",
      root: __dirname,
    },
  },
  tasks: [require("./tasks/user")],
})

Within your task, get and set JSON using dot-style property strings:

export async function user({ config, name, key }) {
  if (key) {
    await config.set(`users.${name}.key`, key)
  }

  console.log(">", config.get(`users.${name}`))
}

Run via CLI:

./run user --name=bob --key=~/.ssh/id_rsa
> { key: "~/.ssh/id_rsa" }

All options

| Option | Example | Purpose | | -------- | --------------------------------------------- | -------------------------------------------- | | alias | {h: ["help"]} | CLI arguments aliases | | preSetup | [config=>config] | Pre-setup functions (before argv parsing) | | setup | [config=>config] | Setup functions | | stores | {store: {root: __dirname, pattern: "**/*"}} | Store configurations | | teardown | [args=>{}] | Teardown functions | | tasks | [{ task: ({})=>{} }] | Task functions |