3.0.6 • Published 4 years ago

@b08/spawn v3.0.6

Weekly downloads
35
License
MIT
Repository
gitlab
Last release
4 years ago

@b08/spawn, seeded from @b08/library-seed, library type: support

Method to spawn process to work on both linux and windows. \ Works with recommended shell parameter. \ Second function is to capture process output.

usage

spawn is just cross-platform (Linux/Windows) spawn converted to promise. Stdio is set to "inherit"

import { spawn } from "@b08/spawn";

async function compileTypescript(): Promise<void> {
  await spawn("npx", "tsc");
}

spawnIt command captures process output, allows to set up process options, except stdio, which is set to {"ignore", "pipe", "inherit"}

import { spawnIt } from "@b08/spawn";

async function collectLocTask(): Promise<void> {
  const locOutput = await spawnIt("npx", ["sloc", "./src"]);
  const regex = /\s*Source\s*:\s*(\d+)\s*/;
  const match = locOutput.match(regex);
  const loc = +match[1];
  // do something with collected Lines Of Code metrics
}

If error happens in the spawned process (exit code is not 0), it prints out collected output to console and throws error.

3.0.6

4 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago