Skip to content

iAmNathanJ/plex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plex

Simple process runner for Deno - a thin wrapper around Deno.run.

Usage

Single Process

import { Process } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";

const proc = new Process({
  name: "my-process",
  cmd: "deno some-file.ts"
});

proc.on("stdout", event => {
  // e.target will be a Process object
  Deno.stdout.writeSync(event.detail);
});

proc.on("stderr", event => {
  // e.target will be a Process object
  Deno.stderr.writeSync(event.detail);
});

proc.start();

await proc.complete();

Multiple Processes

import { Process, Plex } from "https://denopkg.com/iamnathanj/[email protected]/mod.ts";

const multiProcess = new Plex([
  new Process({
    name: "process-1",
    cmd: "echo 1"
  }),
  new Process({
    name: "process-2",
    cmd: "echo 2"
  })
]);

// .listen will read from both stdout and stderr
multiProcess.listen(e => {
  // e.target will be a Process object
  Deno.stdout.writeSync(e.detail);
});

multiProcess.start()

await multiProcess.complete();

Watching

Watching uses file system polling with fs-poll. This is temporary and will be replaced with Deno fsEvents soon.

new Process({ name: "my process", cmd: "long running"}).watch({ root: Deno.cwd() });

Chaining

Things are chainable if you like that sort of thing.

await new Process({ name: "my process", cmd: "some task" })
  .watch({ root: Deno.cwd() })
  .on("stdout", e => Deno.stdout.writeSync(e.detail))
  .on("stderr", e => Deno.stdout.writeSync(e.detail))
  .start()
  .complete();
await new Plex([
  new Process({ name: "proc-1", cmd: "my cmd"}).watch({ root: "./some/dir" }),
  new Process({ name: "proc-2", cmd: "my cmd 2" }).watch({ root: "some/other/dir" })
])
  .listen(e => Deno.stdout.writeSync(e.detail))
  .start()
  .complete();

About

Deno process multiplexer

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published