Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
♻️ Better environment variables for child terms
Browse files Browse the repository at this point in the history
  • Loading branch information
GitSquared committed Apr 29, 2019
1 parent 0d1d1c1 commit 57f93d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/_boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,30 @@ function createWindow(settings) {
signale.watch("Waiting for frontend connection...");
}

app.on('ready', () => {
app.on('ready', async () => {
signale.pending(`Loading settings file...`);
let settings = require(settingsFile);
signale.success(`Settings loaded!`);

if (!require("fs").existsSync(settings.cwd)) throw new Error("Configured cwd path does not exist.");

let customEnv;

// See #366
if (process.platform === "darwin") {
const shellEnv = require("shell-env");
customEnv = shellEnv.sync();
}
let cleanEnv = await require("shell-env")(settings.shell).catch(e => { throw e; });

Object.assign(cleanEnv, process.env, settings.env, {
TERM: "xterm-256color",
COLORTERM: "truecolor",
TERM_PROGRAM: "eDEX-UI",
TERM_PROGRAM_VERSION: app.getVersion()
});

signale.pending(`Creating new terminal process on port ${settings.port || '3000'}`);
tty = new Terminal({
role: "server",
shell: settings.shell.split(" ")[0],
params: settings.shell.split(" ").splice(1),
cwd: settings.cwd,
env: customEnv || settings.env,
env: cleanEnv,
port: settings.port || 3000
});
signale.success(`Terminal back-end initialized!`);
Expand Down Expand Up @@ -235,7 +237,7 @@ app.on('ready', () => {
shell: settings.shell.split(" ")[0],
params: settings.shell.split(" ").splice(1),
cwd: tty.tty._cwd || settings.cwd,
env: customEnv || settings.env,
env: cleanEnv,
port: port
});
signale.success(`New terminal back-end initialized at ${port}`);
Expand Down
4 changes: 2 additions & 2 deletions src/classes/terminal.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ class Terminal {
}
}, 1000);

this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || [], {
name: "xterm-color",
this.tty = this.Pty.spawn(opts.shell || "bash", opts.params || ["--login"], {
name: "xterm-256color",
cols: 80,
rows: 24,
cwd: opts.cwd || process.env.PWD,
Expand Down

0 comments on commit 57f93d8

Please sign in to comment.