1.0.6 • Published 7 years ago

launchpod v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

LaunchPod

LaunchPod is a lightweight and flexible Node.js module which aims to ease the development process. Think Nodemon + REPL.

Instalation

npm install launchpod

and

node node_modules/launchpod your-app.js

or

node node_modules/launchpod your-app your-config-file

Features

REPL

  • Type this and see which properties and methods are exposed at your app.
  • Run/evaluate functions, promises and properties.
  • Objects are pretty printed with Node's util.inspect.
  • Execute a function returning a promise and receive the resolved value.
  • Type a function name and see it's String representation.

Remote REPL

  • Send commands to your app from another application, terminal or script. Eg.: Restart you app from Sublime Text with a single shortcut.

Uncaught Exception handling

  • launchpod will ask if it should quit or restart on Uncaught Exceptions.

(Simple) file watching and restart

  • launchpod can be set to restart your application if any .js file was created or modified.

More

  • No strings attached. No need to keep this module while in production.
  • Lifecycle events - a beforeShutdownCmd function can be set to run before quitting or restarting the app.
  • Lightweight, just native dependencies.

Default commands

Type .help while in REPL to list available commands.

.commandaction
.quitAppQuit application
.qaQuit application (alias)
.restartRestart application
.rsRestart application (alias)
.watcherOffDisable restart on file changes
.wofDisable restart on file changes (alias)
.watcherOnEnable restart on file changes
.wonEnable restart on file changes (alias)

Configuration file reference

A configuration can be specified as follows: node node_modules/launchpod your-app your-config-file

Config files are simple JSON files.

propertyeffect
welcomeMessageString - Sets the welcome message displayed when an user connects on REPL. Eg.: "We have liftoff!"
promptSymbolString - Sets a custom prompt symbol. Eg.: "⚡️ ". Default: '_ '
beepOnUncaughtExceptionBool - Enable terminal bell on Uncaught Exceptions. Default: false
beforeShutdownCmdString - Sets a script to be evaluated before the app's shutdown. Eg.: beforeShutdown(); bye();
watchFileChangeBool - Enables app restart on file changes. Default: false
watcherThrottleTimeNumber - Delay of app restart in milliseconds

How to...

Use REPL from another terminal instance

While in the app directory, use NetCat: nc -U ./socket-ctl

Type .exit to quit remote REPL.

Restart with a script or from another app

echo ".restart" | nc -U ./socket-ctl

Restart app from Sublime Text

  • Create a new Build System with the following content:
{
  "shell_cmd": "echo \".restart\" | nc -U ./socket-ctl",
  "working_dir": "${project_path:${folder}}"
}
  • Save the build file
  • Set the build system with your new file
  • Command+B or Control+B will trigger the build system, restarting your app. ;-)

Load a script once

  • Connect to the REPL: nc -U ./socket-ctl
  • Type: .load your-script

Scope, globals, etc...

The REPL scope is restricted to you app, there is no access to any of Node's globals.

If you wish any of this, expose it in your app's module.

Example

var app = {
  console,
  require,
  beforeShutdown: () => {
    console.log("beforeShutdown stuff is being done ...");
  },
}

module.exports = app;

Restart on file changes

Set true for the key watchFileChange at your configuration file. Don't forget to use the config file:

node node_modules/launchpod your-app your-config-file

Credits

Icon designed by Freepik

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago