Skip to content

Commit 8d1a413

Browse files
save file
1 parent a2dba5f commit 8d1a413

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@
871871

872872
mod.stack.complete;
873873

874-
874+
term.write('node ');
875+
await spawn('node -v');
876+
term.write('npm ');
877+
await spawn('npm -v');
875878

876879

877880
webcontainer.on('server-ready',(port,url)=>{
@@ -957,6 +960,21 @@
957960
})();
958961

959962

963+
//:
964+
965+
966+
async function spawn(cmdline){
967+
968+
var args = cmdline.split(' ');
969+
var cmd = args.shift();
970+
var process = await webcontainer.spawn(cmd,args,{cwd,output:true});
971+
var stream = new WritableStream({write(data){term.write(data)}});
972+
process.output.pipeTo(stream)
973+
var code = await process.exit;
974+
return code;
975+
976+
}//spawn
977+
960978

961979
async function prompt(){
962980

@@ -1000,12 +1018,12 @@
10001018
}//stop
10011019

10021020

1003-
1004-
1005-
1006-
1007-
1008-
1021+
//:
1022+
1023+
1024+
1025+
1026+
10091027
</script>
10101028

10111029
</html>

0 commit comments

Comments
 (0)