Browse Source

Add `now.env` in package.json as env source (#119)

This adds package.json as new source for environment variables, which
are merged with `-e` CLI arguments (CLI args take precedence).

With the ability to specify environment variables in package.json,
developers don't need to remember which `-e` arguments to add, and
can simply run `now`.

```json
"now": {
  "env": {
    "foo": "bar"
  }
}
```

The above is the same as running:
```
now -e foo=bar
```

Fixes #116
master
Eric Ferraiuolo 8 years ago
committed by Leo Lamprecht
parent
commit
ec76f6b706
  1. 15
      bin/now-deploy.js

15
bin/now-deploy.js

@ -21,6 +21,7 @@ import Now from '../lib'
import toHumanPath from '../lib/utils/to-human-path'
import promptOptions from '../lib/utils/prompt-options'
import {handleError, error} from '../lib/error'
import readMetaData from '../lib/read-metadata'
const argv = minimist(process.argv.slice(2), {
string: [
@ -291,8 +292,20 @@ async function sync(token) {
}
}
const {pkg: {now: pkgConfig = {}} = {}} = await readMetaData(path, {
deploymentType,
isStatic,
quiet: true
})
const now = new Now(apiUrl, token, {debug})
const envs = [].concat(argv.env || [])
// Merge `now.env` from package.json with `-e` arguments.
const pkgEnv = pkgConfig.env
const envs = [
...Object.keys(pkgEnv || {}).map(k => `${k}=${pkgEnv[k]}`),
...(argv.env || [])
]
let secrets
const findSecret = async uidOrName => {

Loading…
Cancel
Save