Documentation ¶
Index ¶
- Variables
- func Command(command string, a ...string) (output string, err error)
- func Exists(dir string) bool
- func MustCommand(command string, a ...string) (output string)
- func NodeModuleAbs(relativePath string) string
- func NodeModuleExists(execPath string) bool
- func NodeModulesPath() string
- type Cmd
- type NodeModuleResult
Constants ¶
This section is empty.
Variables ¶
var PathSeparator = string(os.PathSeparator)
PathSeparator is the string of os.PathSeparator
Functions ¶
func MustCommand ¶
MustCommand executes a command in shell and returns it's output, it's block version. It panics on an error
func NodeModuleAbs ¶
NodeModuleAbs returns the absolute path of the global node_modules directory + relative
func NodeModuleExists ¶
NodeModuleExists returns true if a module exists here we have two options 1 . search by command something like npm -ls -g --depth=x 2. search on files, we choose the second
func NodeModulesPath ¶
func NodeModulesPath() string
NodeModulesPath sets the root directory for the node_modules and returns that
Types ¶
type Cmd ¶
Cmd is a custom struch which 'implements' the *exec.Cmd
func CommandBuilder ¶
CommandBuilder creates a Cmd object and returns it accepts 2 parameters, one is optionally first parameter is the command (string) second variatic parameter is the argument(s) (slice of string)
the difference from the normal Command function is that you can re-use this Cmd, it doesn't execute until you call its Command function
func (*Cmd) AppendArguments ¶
AppendArguments appends the arguments to the exists
func (*Cmd) Arguments ¶
Arguments sets the command line arguments, including the command as Args[0]. If the args parameter is empty or nil, Run uses {Path}.
In typical use, both Path and args are set by calling Command.
func (*Cmd) Directory ¶
Directory sets the working directory of the command. If workingDirectory is the empty string, Run runs the command in the calling process's current directory.
func (*Cmd) ResetArguments ¶
ResetArguments resets the arguments
type NodeModuleResult ¶
type NodeModuleResult struct { // Message the message (string) Message string // Error the error (if any) Error error }
NodeModuleResult holds Message and Error, if error != nil then the npm command has failed
func NodeModuleInstall ¶
func NodeModuleInstall(moduleName string) NodeModuleResult
NodeModuleInstall installs a module
func NodeModuleUnistall ¶
func NodeModuleUnistall(moduleName string) NodeModuleResult
NodeModuleUnistall removes a module
func (NodeModuleResult) Output ¶
func (res NodeModuleResult) Output() (out string)
Output returns the error message if result.Error exists, otherwise returns the result.Message