Make preserveEnv return a new object
Modifying the object didn't feel quite right, plus this makes the code a bit more compact.
This commit is contained in:
@@ -236,8 +236,11 @@ export const isPromise = (value: any): value is Promise<any> => {
|
||||
* When spawning VS Code tries to preserve the environment but since it's in
|
||||
* the browser, it doesn't work.
|
||||
*/
|
||||
export const preserveEnv = (options?: { env?: NodeJS.ProcessEnv } | null): void => {
|
||||
if (options && options.env) {
|
||||
options.env = { ...process.env, ...options.env };
|
||||
}
|
||||
export const withEnv = <T extends { env?: NodeJS.ProcessEnv }>(options?: T): T | undefined => {
|
||||
return options && options.env ? {
|
||||
...options,
|
||||
env: {
|
||||
...process.env, ...options.env,
|
||||
},
|
||||
} : options;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user