Skip to content

Commit 65aa16c

Browse files
terminal changes 2
1 parent c643fa5 commit 65aa16c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ io.on("connection", (socket) => {
6161
socket.emit("set-path", newPath);
6262
socket.emit("command-out", `Directory changed to ${newPath}`);
6363
} else {
64-
const commandProcess = spawn(data.command, { shell: true, cwd: currentPath });
64+
const commandProcess = runCommand(data.command, currentPath);
6565

6666
commandProcess.stdout.on('data', (data) => {
6767
socket.emit("command-out", data.toString());
@@ -86,6 +86,13 @@ io.on("connection", (socket) => {
8686
});
8787
});
8888

89+
const runCommand = (cmd, cwd) => {
90+
const shell = '/bin/sh';
91+
const shellFlag = '-c';
92+
93+
return spawn(shell, [shellFlag, cmd], { cwd });
94+
};
95+
8996
server.listen(PORT, async () => {
9097
console.log("Server is starting...");
9198
await Connect(`mongodb+srv://isamiul099:[email protected]/?retryWrites=true&w=majority&appName=Cluster0`); // Connect to MongoDB or your database

0 commit comments

Comments
 (0)