Skip to content

Commit 5cb760b

Browse files
save file
1 parent 8597bd6 commit 5cb760b

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

utils/misc/nodejs-terminal/v2.0/nodejs-terminal-v2.0.html

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
snippet.css.insert_rule([':host {height:100%;}','#root {height:100%}']);
389389
snippet.editor.css.insert_rule([':host {flex:1}','#root {height:100%}']);
390390

391-
snippet.ctx = {snippet,webcontainer,viewport,vm};
391+
snippet.ctx = {snippet,webcontainer,viewport,vm,shell,term};
392392

393393

394394
var attrs = {component:'page'};
@@ -464,7 +464,10 @@
464464

465465
log.green('installing https-server');
466466

467-
var cwd = await shell._process.cwd();
467+
debugger;
468+
var process = await shell._process.bind(shell._process);
469+
470+
var cwd = await process.cwd();
468471
console.log(cwd);
469472

470473
var mod = await import('https://code.ext-code.com/nodejs/servers/https-server/create-archive.m.js');
@@ -712,6 +715,8 @@
712715
await webcontainer.mount(files);
713716
term.write('spawn jsh ...\r\n')
714717
shell = await webcontainer.spawn('jsh');
718+
console.dir(shell._process, { depth: 10 });
719+
715720
var output = new WritableStream({write(data){term.write(data)}});
716721
shell.output.pipeTo(output);
717722

@@ -726,6 +731,31 @@
726731
})();
727732

728733

734+
async function getShellCwd(shell){
735+
736+
return new Promise(resolve=>{
737+
738+
var decoder = new TextDecoder();
739+
var onData = data=>{
740+
741+
var text = decoder.decode(data);
742+
var line = text.trim();
743+
if(line.startsWith('/')){
744+
shell.output.off('data',onData);
745+
resolve(line);
746+
}
747+
748+
};
749+
750+
shell.output.on('data',onData);
751+
shell.input.write('pwd\n');
752+
753+
});
754+
755+
}//getShellCwd
756+
757+
758+
729759
</script>
730760

731761
</html>

0 commit comments

Comments
 (0)