Start development server when run button is clicked.
This commit is contained in:
parent
a74f7bf71a
commit
6a31161c0a
@ -36,7 +36,7 @@ export default function RunButtonModal({
|
||||
console.log('Opening Preview Window');
|
||||
|
||||
if (terminals.length < 4) {
|
||||
createNewTerminal();
|
||||
createNewTerminal("yarn install && yarn start");
|
||||
} else {
|
||||
toast.error("You reached the maximum # of terminals.");
|
||||
console.error('Maximum number of terminals reached.');
|
||||
|
@ -13,7 +13,7 @@ interface TerminalContextType {
|
||||
setActiveTerminalId: React.Dispatch<React.SetStateAction<string>>;
|
||||
creatingTerminal: boolean;
|
||||
setCreatingTerminal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
createNewTerminal: () => void;
|
||||
createNewTerminal: (command?: string) => Promise<void>;
|
||||
closeTerminal: (id: string) => void;
|
||||
setUserAndSandboxId: (userId: string, sandboxId: string) => void;
|
||||
}
|
||||
@ -50,7 +50,7 @@ export const TerminalProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
}
|
||||
}, [userId, sandboxId]);
|
||||
|
||||
const createNewTerminal = async () => {
|
||||
const createNewTerminal = async (command?: string): Promise<void> => {
|
||||
if (!socket) return;
|
||||
setCreatingTerminal(true);
|
||||
try {
|
||||
@ -58,6 +58,7 @@ export const TerminalProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
setTerminals,
|
||||
setActiveTerminalId,
|
||||
setCreatingTerminal,
|
||||
command,
|
||||
socket,
|
||||
});
|
||||
} catch (error) {
|
||||
|
@ -8,6 +8,7 @@ export const createTerminal = ({
|
||||
setTerminals,
|
||||
setActiveTerminalId,
|
||||
setCreatingTerminal,
|
||||
command,
|
||||
socket,
|
||||
}: {
|
||||
setTerminals: React.Dispatch<React.SetStateAction<{
|
||||
@ -16,6 +17,7 @@ export const createTerminal = ({
|
||||
}[]>>;
|
||||
setActiveTerminalId: React.Dispatch<React.SetStateAction<string>>;
|
||||
setCreatingTerminal: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
command?: string;
|
||||
socket: Socket;
|
||||
|
||||
}) => {
|
||||
@ -29,6 +31,7 @@ export const createTerminal = ({
|
||||
setTimeout(() => {
|
||||
socket.emit("createTerminal", id, () => {
|
||||
setCreatingTerminal(false);
|
||||
if (command) socket.emit("terminalData", id, command + "\n");
|
||||
});
|
||||
}, 1000);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user