Documentation
¶
Overview ¶
Package gode runs a sandboxed node installation to run node code and install npm packages.
Index ¶
- Constants
- type Client
- func (c *Client) DebugScript(script string) *exec.Cmd
- func (c *Client) InstallPackage(name string) error
- func (c *Client) IsSetup() bool
- func (c *Client) NodeBase() string
- func (c *Client) Packages() ([]Package, error)
- func (c *Client) RemovePackage(name string) error
- func (c *Client) RunScript(script string) *exec.Cmd
- func (c *Client) Setup() error
- func (c *Client) UpdatePackage(name string) (string, error)
- func (c *Client) UpdatePackages() (string, error)
- type Package
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.
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) DebugScript ¶
DebugScript is the same as RunScript except it launches with node-inspector
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!
func (*Client) UpdatePackage ¶
UpdatePackage updates a package.
func (*Client) UpdatePackages ¶
UpdatePackages updates all packages.