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

ok-runner

v1.0.0

Published

A task runner that works just fine

Downloads

4

Readme

Motivation

I usually use npm scripts extensively as a build tool when building libraries. Though this leads to my package.json becoming bloated and does not allow for proper commenting of longer commands. I wanted a simple build tool that allowed me to execute commands and functions(in more complex cases) with minimal effort. The popular solutions felt like overkill so I made my own. It ain't the next big thing, but it works fine.

Install

$ npm install --save ok-runner
# Or
$ yarn add ok-runner

Usage

Create a js file in your project directory. for example ok.js

In ok.js:


const ok = require('ok-runner')

ok
  .run('Greet', 'echo Hello!')
  .run('Do some logging', () => {
    console.log('log')
    console.log('All')
    console.log('The')
    console.log('Things!')
  })
  .run('Touch a file', 'touch aFile')
  .run('Remove a file', 'rm aFile')

You can then run the file in your terminal:

$ node ok.js

If the second argument is a string, it will be wrapped in a the ok.exec property that supports executing locally installed binaries by name.

Or you can run specific commands by using the cli. Modify your ok.js:


const ok = require('ok-runner')

ok
  .task('Greet', 'echo Hello!')
  .task('Do some logging', () => {
    console.log('log')
    console.log('All')
    console.log('The')
    console.log('Things!')
  })
  .task('Touch a file', 'touch aFile')
  .task('Remove a file', 'rm aFile')

module.exports.ok

Then, after installing globally or via your npm scripts:

$ ok Greet

This will execute only the hello task. only running ok will run all the tasks

The cli looks for a file named ok.js otherwise you must specify the script name:

ok --script=example.js

API

The module exports a singleton ok object with the following methods:

ok.run(taskName: String, handler: String|Function)

Runs a task with the given taskName by executing the given string command or function. If no handler is provided, the created tasks are checked for a matching task and executed

ok.task(taskName: String, handler: String|Function)

Creates a new task with name taskName that can be ran using the ok.run method or via the cli.

ok.args

An object containing all the argument options parsed using get-them-args

ok.exec(command, options, cb)

A simple wrapper around shelljs's exec method after extending it support executing locally installed binaries by name.

Example

Please check the example directory.

Contribute

Contributions are welcome. Please open up an issue or create PR if you would like to help out.

Note: If editing the README, please conform to the standard-readme specification.

License

Licensed under the MIT License.