Skip to content

Commit

Permalink
Update readme to reflect v2.0.0 API
Browse files Browse the repository at this point in the history
  • Loading branch information
doesdev committed May 29, 2017
1 parent 4db70e9 commit 89199c9
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ngo [![NPM version](https://badge.fury.io/js/ngo.svg)](https://npmjs.org/package/ngo) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

> Run go commands, whether your go env is in place or not
> Run go commands, whether your GO env is in place or not
Will download latest binaries locally if GO isn't already in PATH

Expand All @@ -18,40 +18,30 @@ $ npm install --global ngo

## api

### ngo
returns promise which resolves to [`execa`](https://github.com/sindresorhus/execa) styled object
- **arguments** *(Array, arguments to call with `go` command - required)*
### require('ngo')(opts)
accepts `opts` as below, returns `ngo` function which executes GO commands
- **options** *(Object - optional)*
- **useLocal** *(Boolean, use locally downloaded GO binaries - optional)*
- **env** *(Object, environment vars to set for the GO command - optional)*
- **goRoot** *(String, GO root path (ex. `/usr/local/go`) - optional)*
- **goPath** *(String, GO workspace path (ex. `~/work`) - optional)*
- **reject** *(Boolean, set to `false` to resolve the promise on stderr instead of rejecting - optional)*

### ngo.init
returns promise that resolves when `ngo` is ready for `cmd`
- **options** *(Object - optional)*
- **useLocal** *(Boolean, use locally downloaded GO binaries - optional)*

### ngo.cmd
returns `execa` styled [`child_process`](https://nodejs.org/api/child_process.html#child_process_class_childprocess) instance with promise-cuity
- **command** *(String, (ex. 'build') - optional - if ommitted signature is shifted)*
- **arguments** *(Array, arguments to call with `go` command - optional)*
### ngo(arguments, options)
returns promise which resolves to [`execa`](https://github.com/sindresorhus/execa) styled object
- **arguments** *(Array | String, argument(s) to call with `go` command - required)*
- **options** *(Object - optional)*
- **env** *(Object, environment vars to set for the GO command - optional)*
- **goRoot** *(String, GO root path (ex. `/usr/local/go`) - optional)*
- **goPath** *(String, GO workspace path (ex. `~/work`) - optional)*
- **reject** *(Boolean, set to `false` to resolve the promise on stderr instead of rejecting - optional)*
- same options as [`child_process.spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options)
- additonal options available same as [`execa`](https://github.com/sindresorhus/execa#options)

## usage

#### cli usage
```sh
$ ngo version
# go version go1.7.1 windows/amd64
# go version go1.8.3 windows/amd64
```

#### default usage
#### programmatic usage
returns promise that resolves to `execa` style object without the `child_process` goodies

```js
Expand All @@ -60,7 +50,7 @@ const ngo = require('ngo')(goOpts)

ngo('version').then(console.log).catch(console.error)
/* {
stdout: 'go version go1.7.1 windows/amd64',
stdout: 'go version go1.8.3 windows/amd64',
stderr: '',
code: 0,
failed: false,
Expand Down

0 comments on commit 89199c9

Please sign in to comment.