Skip to content

Commit

Permalink
add _DELIMITER_ to split env and uselessheader (#11)
Browse files Browse the repository at this point in the history
* add _DELIMITER_ to split env and uselessheader

* make code simpler
  • Loading branch information
saltfish666 authored and silverwind committed Jun 20, 2018
1 parent 19d4cc8 commit f4676bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -3,12 +3,13 @@ const execa = require('execa');
const stripAnsi = require('strip-ansi');
const defaultShell = require('default-shell');

const args = ['-ilc', 'env; exit'];
const args = ['-ilc', 'echo -n "_SHELL_ENV_DELIMITER_"; env; echo -n "_SHELL_ENV_DELIMITER_"; exit'];

function parseEnv(env) {
env = env.split('_SHELL_ENV_DELIMITER_')[1];
const ret = {};

for (const line of stripAnsi(env).split('\n')) {
for (const line of stripAnsi(env).split('\n').filter(line => Boolean(line))) {
const parts = line.split('=');
ret[parts.shift()] = parts.join('=');
}
Expand Down

0 comments on commit f4676bf

Please sign in to comment.