(action: ActionState)
| 122 | } |
| 123 | |
| 124 | async #runShellAction(action: ActionState) { |
| 125 | if (action.type !== 'shell') { |
| 126 | unreachable('Expected shell action'); |
| 127 | } |
| 128 | |
| 129 | const webcontainer = await this.#webcontainer; |
| 130 | |
| 131 | const process = await webcontainer.spawn('jsh', ['-c', action.content], { |
| 132 | env: { npm_config_yes: true }, |
| 133 | }); |
| 134 | |
| 135 | action.abortSignal.addEventListener('abort', () => { |
| 136 | process.kill(); |
| 137 | }); |
| 138 | |
| 139 | process.output.pipeTo( |
| 140 | new WritableStream({ |
| 141 | write(data) { |
| 142 | console.log(data); |
| 143 | }, |
| 144 | }), |
| 145 | ); |
| 146 | |
| 147 | const exitCode = await process.exit; |
| 148 | |
| 149 | logger.debug(`Process terminated with code ${exitCode}`); |
| 150 | } |
| 151 | |
| 152 | async #runFileAction(action: ActionState) { |
| 153 | if (action.type !== 'file') { |
no test coverage detected