Documentation
¶
Overview ¶
Package gode runs a sandboxed node installation to run node code and install npm packages.
Index ¶
Examples ¶
Constants ¶
const DefaultNodeVersion = "1.1.0"
The Node version to install. Override this by setting client.Version.
const DefaultNpmVersion = "2.4.1"
The NPM version to install. Override this by setting client.Version.
const NodeCDN = "http://d1gnwkq6ucr1xr.cloudfront.net"
This is a Cloudfront CDN that mirrors http://iojs.org/dist It is much faster.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the interface between Node and Go. It also setups up the Node environment if needed.
func NewClient ¶
NewClient creates a new Client at the specified rootPath The Node installation can then be setup here with client.Setup()
func (*Client) InstallPackage ¶
InstallPackage installs an npm package.
func (*Client) RemovePackage ¶
RemovePackage removes an npm package.
func (*Client) RunScript ¶
RunScript runs a given script in node Returns an *os/exec.Cmd instance
Example ¶
c := NewClient("tmp")
err := c.Setup()
if err != nil {
panic(err)
}
output, err := c.RunScript(`console.log("hello world!")`).CombinedOutput()
if err != nil {
panic(err)
}
fmt.Println(string(output))
Output: hello world!