Skip to content

kbrw/nox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Nox

Embeds node, npm and provides wrappers for running it.

Installation

If available in Hex, the package can be installed by adding nox to your list of dependencies in mix.exs:

def deps do
  [
    {:nox, "~> 0.1.0"}
  ]
end

The docs is available at https://hexdocs.pm/nox

Usage

Nox can manage multiple environments. All functions take as argument an environment. A default one can be obtained with:

Nox.Env.default()

Custom ones can be built with:

Nox.Env.new(options)

Get full path to executable:

Nox.which(env, "node")

Get OS env for executing command in the node environment, for instance to give to env option of System.cmd/3:

env = Nox.sys_env(Nox.Env.default())
System.cmd("aglio", ["-i", "doc.in", "-o", "doc.out"], env: env)

Nox provides also wrappers for some well-know commands: see Nox.Npm, Nox.Grunt.

Command line parsers

Nox includes tools for parsing command line output, as for into option of System.cmd/3.

If you simply want to redirect command output to Logger:

System.cmd("echo", ["\"my tailor is rich\""], into: Nox.Cli.stream())

If you want to use a custom parser:

System.cmd("npm", ["install"], into: Nox.Cli.stream({Nox.Parsers.Npm, []}))

License

Nox source code is released under Apache 2 License.

Check the LICENSE file for more information.