Documentation
¶
Overview ¶
Package gode runs a sandboxed node installation to run node code and install npm packages.
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultNodeVersion = "1.1.0"
The Node version to install. Override this by setting client.Version.
View Source
const DefaultNpmVersion = "2.4.1"
The NPM version to install. Override this by setting client.Version.
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!
Click to show internal directories.
Click to hide internal directories.