Skip to content

Commit

Permalink
Expose environment vars
Browse files Browse the repository at this point in the history
  • Loading branch information
doesdev committed Mar 18, 2018
1 parent 6be816f commit e75a398
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ jspm_packages
vendor/go
vendor/*.zip
vendor/*.tar.gz

# Anything other than gitkeep in vendor dirs
vendor/gopath/bin/*
!vendor/gopath/bin/.gitkeep
vendor/gopath/pkg/*
!vendor/gopath/pkg/.gitkeep
vendor/gopath/src/*
!vendor/gopath/src/.gitkeep
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ ngo('version').then(console.log).catch(console.error)

## api

### require('ngo')(opts)
accepts `opts` as below, returns `ngo` function which executes Go commands
### const ngo = require('ngo')(opts)
accepts `opts` as below, returns `ngo` function which executes Go commands,
- **options** *[Object - optional]*
- **useLocal** *[Boolean `false`] - use locally downloaded Go binaries)*
- **update** *[Boolean `false`] - update local install to latest*
Expand All @@ -71,6 +71,9 @@ returns promise which resolves to [`execa`](https://github.com/sindresorhus/exec
- 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)

### ngo.env
this is a copy of ngo's `process.env` with the Go environment variables added to it

## License

MIT © [Andrew Carpenter](https://github.com/doesdev)
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ module.exports = (opts = {}) => {
env.ngoBin = path.join(goRoot, 'bin', 'go')
try { env.hasBin = exists(path.join(goRoot, 'bin')) } catch (ex) {}
if (opts.update) delete env.hasBin
return (args, cmdOpts = {}) => {
let ngoRunner = (args, cmdOpts = {}) => {
if (opts.update) args = args || ['version']
return runner(args, Object.assign({}, cmdOpts, {env}))
}
ngoRunner.env = env
return ngoRunner
}

function runner (args, opts) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngo",
"version": "2.4.3",
"version": "2.4.4",
"description": "Run Go commands, whether your Go env is in place or not",
"main": "index.js",
"files": [
Expand Down

0 comments on commit e75a398

Please sign in to comment.