npm

package
v8.3.4+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2017 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathSeparator is the string of os.PathSeparator
	PathSeparator = string(os.PathSeparator)
)

Functions

func Command

func Command(command string, a ...string) (output string, err error)

Command executes a command in shell and returns it's output, it's block version

func Exists

func Exists(dir string) bool

Exists returns true if directory||file exists

func MustCommand

func MustCommand(command string, a ...string) (output string)

MustCommand executes a command in shell and returns it's output, it's block version. It panics on an error

func NodeModuleAbs

func NodeModuleAbs(relativePath string) string

NodeModuleAbs returns the absolute path of the global node_modules directory + relative

func NodeModuleExists

func NodeModuleExists(execPath string) bool

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

type Cmd struct {
	*exec.Cmd
}

Cmd is a custom struch which 'implements' the *exec.Cmd

func CommandBuilder

func CommandBuilder(command string, args ...string) *Cmd

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

func (cmd *Cmd) AppendArguments(args ...string) *Cmd

AppendArguments appends the arguments to the exists

func (*Cmd) Arguments

func (cmd *Cmd) Arguments(args ...string) *Cmd

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

func (cmd *Cmd) Directory(workingDirectory string) *Cmd

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

func (cmd *Cmd) ResetArguments() *Cmd

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL