Skip to content

Commit

Permalink
fix: wasi cli interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 23, 2023
1 parent ad3f549 commit 8e97b92
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
18 changes: 16 additions & 2 deletions packages/preview2-shim/lib/browser/cli.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
let _env;
let _env, _args = [], _cwd = null;
export function _setEnv (envObj) {
_env = Object.entries(envObj);
}

export function _setArgs (args) {
_args = args;
}

export function _setCwd (cwd) {
_cwd = cwd;
}

export const environment = {
getEnvironment () {
if (!_env) _env = [];
if (!_env) _setEnv(process.env);
return _env;
},
getArguments () {
return args;
},
initialCwd () {
return _cwd;
}
};

Expand Down
24 changes: 17 additions & 7 deletions packages/preview2-shim/lib/nodejs/cli.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
let _env;
let _env, _args = [], _cwd = null;
export function _setEnv (envObj) {
_env = Object.entries(envObj);
}

export function _setArgs (args) {
_args = args;
}

export function _setCwd (cwd) {
_cwd = cwd;
}

export const environment = {
getEnvironment () {
if (!_env) _setEnv(process.env);
return _env;
},
getArguments () {
return args;
},
initialCwd () {
return _cwd;
}
};

Expand Down Expand Up @@ -35,15 +49,11 @@ export const stderr = {
};

export const terminalInput = {
dropTerminalInput () {

}
dropTerminalInput () {}
};

export const terminalOutput = {
dropTerminalOutput () {

}
dropTerminalOutput () {}
};

export const terminalStderr = {
Expand Down

0 comments on commit 8e97b92

Please sign in to comment.