Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jul 1, 2019
1 parent 5c172a1 commit 888e757
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ const {joinCommand, parseCommand} = require('./lib/command.js');

const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;

const getEnv = ({
env: envOption,
extendEnv = true,
preferLocal = false,
cwd,
localDir = cwd || process.cwd()
}) => {
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir}) => {
const env = extendEnv ? {...process.env, ...envOption} : envOption;

if (preferLocal) {
Expand All @@ -40,14 +34,18 @@ const handleArgs = (file, args, options = {}) => {
maxBuffer: DEFAULT_MAX_BUFFER,
buffer: true,
stripFinalNewline: true,
extendEnv: true,
preferLocal: false,
localDir: options.cwd || process.cwd(),
encoding: 'utf8',
reject: true,
cleanup: true,
...options,
env: getEnv(options),
windowsHide: true
};

options.env = getEnv(options);

options.stdio = normalizeStdio(options);

if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {
Expand Down

0 comments on commit 888e757

Please sign in to comment.