Repository
Current version released
3 years ago
Dependencies
std
Versions
- v1.1.5Latest
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.77
- v1.0.76
- v1.0.75
- v1.0.74
- v1.0.73
- v1.0.72
- v1.0.71
- v1.0.70
- v1.0.69
- v1.0.68
- v1.0.67
- v1.0.66
- v1.0.65
- v1.0.64
- v1.0.63
- v1.0.62
- v1.0.61
- v1.0.60
- v1.0.59
- v1.0.58
- v1.0.57
- v1.0.56
- v1.0.55
- v1.0.54
- v1.0.53
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
denoexec
A higher level wrapper around
Deno.run
.
Inspired by:
- https://github.com/sindresorhus/execa
- https://github.com/brad-jones/goexec
- https://github.com/brad-jones/dexeca
Why not https://github.com/gpasq/deno-exec?
I don’t want to supply a string as the command to execute, quoting becomes a nightmare, an explicitly defined array of arguments is much more reliable in my experience.
Why not https://github.com/acathur/exec?
It’s too basic, can not easily buffer input or output.
Usage
Traditional API
import { exec } from "https://deno.land/x/denoexec/mod.ts";
// A new child process is started as soon as the exec call is made
const proc = exec({
cmd: ["ping", "1.1.1.1"], /* all other options are provided on this object */
});
// You can do things with the process before it's finished,
// like kill it or read it's io streams, etc...
setTimeout(() => proc.kill(), 1000);
// You need to await for it's completion
const results = await proc;
console.log(results.success);
Functional (Deferred) API
This is an alternative API that provides a subset of functionality and was inspired by the likes of https://github.com/google/zx & https://github.com/Minigugus/bazx
import { $, _, prefix } from "https://deno.land/x/denoexec/mod.ts";
// Use `_` to create a new deferred child process.
// At this point nothing has been executed.
const proc = _`ping 1.1.1.1`;
// You can wrap the process with other functions like this
proc = prefix("foo", proc);
// Or you might apply config to the object directly
proc.prefixSeparator = " -> ";
// Finally start the execution of and await the child processes results
const results = await proc;
console.log(results.success);
// To capture the io instead of stream it to the console you can use the `$`
// function, think of it like bash command substitution.
const branch = $(_`git rev-parse --abbrev-ref HEAD`);
see ./examples for more details