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

multi-proc

v1.1.0

Published

Run multiple processes and view their output combined in a single terminal

Downloads

7

Readme

multi-proc

Run multiple command line operations at the same time. For example, if you want to run your Express backend alongside the Vue frontend, you could use this package to run both from the same terminal instance, and view both logs at the same time.

multi-proc in action

Windows:

This was developed and tested on only OSX and *nix. Windows has not been tested, but it should work with cmd syntax for commands. Cannot guarantee it.

Usage

Installation

You can install it locally or globally:

# Global (Recommended)
npm install -g multi-proc
yarn global add multi-proc

# Local
npm install multi-proc
yarn add multi-proc

Globally would a be a pretty good move if you want to use it outside of a project, so you wouldn't have to create a package.json before using it.

Configuration

~~Generate a configuration file using the init command~~ This hasn't been implemented yet. It's just a json file, so... make it yourself.

multi-proc init

This will generate a file in the working directory called multi-proc.config.json. Paths in this file are not relative to the config file, but to the working directory when the command is called.

[
  {
    "tag": "Process 1",
    "color": "BG_BLUE",
    "command": "yarn start",
    "directory": "/path/to/process1"
  },
  {
    "tag": "Process 2",
    "color": "BG_GREEN",
    "command": "npm run start",
    "directory": "/path/to/process2"
  }
]

This file could also be a .js file as well:

// multi-proc.config.js
module.exports = [
  {
    tag: "Process 1",
    color: "BG_BLUE",
    command: "yarn start",
    directory: "/path/to/process1"
  },
  ...
]

tag

This is the string that is displayed in the terminal output at the beginning of the line when the process prints a line.

color

This is the colorization of the tag when the process outputs a message. Any of the enum names here, such as "BLUE", "BG_RED", "UNDERSCORE", are valid options.

command

Specify the command to start each process. This doesn't have to start a node script, could be any bash command. Be careful when you have to escape characters.

"command": "cd some/directory && yarn start"

directory

Specify the working directory for the "command" to run from. This path should be relative to where the command is used from.

Running

# Run the processes in multi-proc.config.json
multi-proc start

# Filter and only output tags that match regex
multi-proc start --filter 'proc.*?1'

# Run the processes in a specific config file
multi-proc --config path/to/config.json start

# View all commands/options
multi-proc --help

Example 1: Vue + Express

In this case, you only need to run both in the Vue frontend, as the frontend is dependent on the backend.

$ pwd
/home/aklinker1/workspace/Gamer-Elite

$ ls
... express-backend/ ... vue-frontend/ ...

$ cd vue-frontend

$ ls
... multi-proc.config.json ... package.json ...

$ cat multi-proc.config.json
[
  {
    "tag": "Express",
    "color": "BG_BLUE",
    "command": "yarn start:dev",
    "directory": "../express-backend"
  },
  {
    "tag": "Vue",
    "color": "BG_TEAL",
    "command": "yarn serve",
  }
]

$ multi-proc start

Example 2

$ pwd
/home/aaron/programming

$ ls
node-project-1/  node-project-2/  multi-proc.config.json

$ cat multi-proc.config.json
[
  {
    "tag": "Process 1",
    "color": "BG_BLUE",
    "command": "yarn start:dev",
    "directory": "programming/node-project-1"
  },
  {
    "tag": "Project 2",
    "color": "BG_GREEN",
    "command": "cd programming/node-project-2 && node src/index.js"
  }
]

$ cd ..

$ pwd 
/home/aaron

# Note because this isn't running in /home/aaron/programming, I had to add programming/* for the directory on the node-project-1 process and the cd for the node-project-2 process
# Paths in the config need to be relative to where the command is called from
$ multi-proc --config programming/multi-proc.config.json start