Ink by Example — Execing Processes

Ink by Example: Execing Processes

Ink can spawn child processes. The stdout data is passed to a callback when the process ends.

std := load('../vendor/std')
each := std.each
log := std.log

Let's take a look at the files in the directory relative to the executing file (in this instance, this website's build script).

path := 'ls' `` path to executable
arguments := []
stdin := ''
stdoutFn := out => log(out)
exec(path, arguments, stdin, stdoutFn)

args gives us the command-line arguments for the current context. This can be useful if you're chaining Ink programs.

each(args(), arg => log('  ' + arg))

$ ink
{type: 'data', data: '