Skip to content

Latest commit

 

History

History
93 lines (73 loc) · 3.69 KB

README.md

File metadata and controls

93 lines (73 loc) · 3.69 KB

Knob

Knob is a stand-alone binary for MacOS, Windows, and Linux that packages a recent Node LTS release (currently, 16.13.2) along with a collection of third-party packages that are useful for creating CLI utilities.

The intended use case is to place knob within the user's PATH, thus allowing the creation of executable shell scripts in a language more expressive than bash:

#!/usr/bin/env knob

const path = require('path');
const os = require('os');

module.exports = async ({ express, morgan }) => {
  const app = express();
  app.use(morgan('combined'));
  app.use(express.json());

  app.use('/files', express.static(__dirname));

  app.route('/').get((req, res, next) => {
    return res.send({
      message: 'Hello, world.',
    });
  });

  app.listen(9070, () => {
    console.log('App is listening on port: 9070');
  });
};

knobfile.js

If no target script is passed to knob, it will walk up the directory tree in search of a knobfile.js file. If found, it will execute that. Otherwise, it will print an error to the console and exit with status code 1. To override this behavior and prevent knob from searching for knobfile.js, set the IGNORE_KNOBFILE environment variable to 1.

Installing and Updating

To install or update knob, run the install script. To do that, you may either download and run the script manually, or use the following wget or curl command:

wget

wget -qO- https://raw.githubusercontent.com/tkambler/knob/v0.0.6/install.sh | bash

curl

curl -o- https://raw.githubusercontent.com/tkambler/knob/v0.0.6/install.sh | bash

Compiling from Source

Just run make. Distributable binaries for MacOS, Linux, and Windows will be saved to ./dist.

Which packages does it include?