Skip to content
Myr

Separate `process.env`-related logic to its own function (#341)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent c9b4d09 · Browse files · 1 file+12 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−13 removed

  • other:+12 added−13 removed

1 file+12 added−13 removed

modified:index.js+12 added-13 removed
12 unmodified lines
13const {joinCommand, parseCommand} = require('./lib/command.js');1415const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;1617const getEnv = ({env: envOption, extendEnv, preferLocal, localDir}) => {18 const env = extendEnv ? {...process.env, ...envOption} : envOption;1920 if (preferLocal) {21 return npmRunPath.env({env, cwd: localDir});22 }2324 return env;25};2627const handleArgs = (file, args, options = {}) => {28 const parsed = crossSpawn._parse(file, args, options);29 file = parsed.command;30 args = parsed.args;
2 unmodified lines
33 options = {34 maxBuffer: DEFAULT_MAX_BUFFER,35 buffer: true,36 stripFinalNewline: true,37 extendEnv: true,38 preferLocal: false,39 localDir: options.cwd || process.cwd(),40 encoding: 'utf8',41 reject: true,
1 unmodified line
43 ...options,44 windowsHide: true45 };4636 if (options.extendEnv !== false) {37 options.env = {38 ...process.env,39 ...options.env40 };41 }47 options.env = getEnv(options);4843 if (options.preferLocal) {44 options.env = npmRunPath.env({45 ...options,46 cwd: options.localDir47 });48 }4949 options.stdio = normalizeStdio(options);5051 if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {52 // #116
201 unmodified lines