Add support for environment variables in config (#534)

* Allow env to be specified in config (#424)

This is referencing #424. User specified environment variables
in the `.hyperterm.js` file are expected under a field named `env`.

An example config:

```
module.exports = {
  config: {

    ...

    // Environment variables
    env: {
      WHAT_UP: 'heyo',
    }

    ...

  },

  plugins: [],

  localPlugins: []
};
```

* Add env field to default config
This commit is contained in:
Richard Zhao 2016-08-02 00:49:25 -07:00 committed by James Hall
parent 20e8d5e169
commit 011ae3fd52
2 changed files with 8 additions and 2 deletions

View file

@ -54,7 +54,10 @@ module.exports = {
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
// if left empty, your system's login shell will be used by default
shell: ''
shell: '',
// for environment variables
env: {}
// for advanced config flags please refer to https://hyperterm.org/#cfg
},

View file

@ -4,6 +4,7 @@ const { exec } = require('child_process');
const defaultShell = require('default-shell');
const { getDecoratedEnv } = require('./plugins');
const { productName, version } = require('./package');
const config = require('./config');
let spawn;
try {
@ -19,6 +20,8 @@ try {
const TITLE_POLL_INTERVAL = 500;
const envFromConfig = config.getConfig().env || {};
module.exports = class Session extends EventEmitter {
constructor ({ rows, cols: columns, cwd, shell }) {
@ -28,7 +31,7 @@ module.exports = class Session extends EventEmitter {
TERM: 'xterm-256color',
TERM_PROGRAM: productName,
TERM_PROGRAM_VERSION: version
});
}, envFromConfig);
this.pty = spawn(shell || defaultShell, ['--login'], {
columns,