File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -111,14 +111,33 @@ await webcontainer.mount({
111111
112112##### ` runCommand `
113113
114- Run command inside webcontainer. Returns command output.
114+ Run command inside webcontainer.
115115
116116``` ts
117117await webcontainer .runCommand (" npm" , [" install" ]);
118+ ```
119+
120+ Calling ` await ` on the result resolves into the command output:
118121
122+ ``` ts
119123const files = await webcontainer .runCommand (" ls" , [" -l" ]);
120124```
121125
126+ To write into the output stream, use ` write ` method of the non-awaited output.
127+
128+ To verify output of continuous stream, use ` waitForText() ` :
129+
130+ ``` ts
131+ const { write, waitForText, isDone } = webcontainer .runCommand (" npm" , [
132+ " create" ,
133+ " vite" ,
134+ ]);
135+
136+ await waitForText (" What would you like to call your project?" );
137+ await write (" Example Project" );
138+ await isDone ;
139+ ```
140+
122141##### ` readFile `
123142
124143WebContainer's [ ` readFile ` ] ( https://webcontainers.io/guides/working-with-the-file-system#readfile ) method.
You can’t perform that action at this time.
0 commit comments