package
4.29.4+incompatible
Repository: https://github.com/talbright/cli.git
Documentation: pkg.go.dev

# README

gode

Build Status Code Coverage GoDoc

gode runs a sandboxed node installation to run node code and install npm packages.

Usage

Gode will autoinstall Node and npm if it's not in the specified working directory.

To use gode, first give it a working directory. In this case, ~/.gode. You would need to already have a homeDir variable for this to work.

c := NewClient(filepath.Join(homeDir, ".gode"))

Next, call c.Setup() to ensure that gode is setup properly in that working directory.

err := c.Setup()
if err != nil {
    panic(err)
}

Finally, execute a node script. This returns an *os/exec.Cmd:

output, err := c.RunScript(`console.log("hello world!")`).CombinedOutput()
if err != nil {
    panic(err)
}
fmt.Println(string(output))

Or install packages:

err := c.InstallPackages("request")
if err != nil {
    panic(err)
}

Meta

# Functions

ClearCache clears the npm cache.
DebugScript is the same as RunScript except it launches with node-inspector.
InstallPackages installs a npm packages.
IsSetup returns true if node is setup in RootPath.
OutdatedPackages returns a map of packages and their latest version.
Packages returns a list of npm packages installed.
RemovePackages removes a npm packages.
RunScript runs a given script in node Returns an *os/exec.Cmd instance.
SetRootPath sets the root for gode.
Setup downloads and sets up node in the RootPath directory.

# Constants

NodeVersion is the requested node version.
NpmVersion is the requested npm version.

# Structs

Package represents an npm package.