@homeofthings/node-sys
v1.0.2
Published
HomeOfThings - fluent API for spawning child processes and shell-like filesystem function
Downloads
85
Maintainers
Readme
@homeofthings/node-sys
This library is mainly intended to be helpful for build and installation tasks. It includes a Fluent API for spawning child processes and many file-system related functions that work and are named similarly to their shell counterparts.
Fluent API for spawning child processes
const out: string[] = [];
await exec('node', '-e', `console.log("hello world")`).setStdOut(out).run();
const script: string[] = [`console.log("hello world")`];
await exec('node').setStdIn(script).run();
const out: string[] = [];
await sh('ls -l *.md').setStdOut(out).run();
const out: string[] = [];
await pipe(sh('ls -l *.md')).to(exec('wc', '-l').setStdOut(out)).run();
// out[0] contains the number of *.md files as string
file-system related functions
file-system related functions that work and are named similarly to their shell counterparts, e.g.: cd, pwd, pushd, popd, dirs, realpath, stat, which, unlink, ln, mktemp, chmod, chown, mkdir, rm, rmdir, touch, cp, mv, rename, ...
await rm('myfile.bak');
await rm(['myfile.bak', 'mytmpdir'], { recursive: true, force: true });
await rm(glob('**/*.bak'));