Skip to content

Conversation

@Anxhul10
Copy link
Owner

@Anxhul10 Anxhul10 commented Aug 13, 2025

const { spawn } = require('child_process');

export const execCommand = (command) => {
  return new Promise((resolve, reject) => {
    const childProcess = spawn(command, { 
      stdio: 'inherit',
      shell: true
    });
    childProcess.on('error', (error) => {
      reject(error);
    });
    childProcess.on('exit', (code) => {
      if (code === 0) {
        resolve();
      } else {
        reject(new Error(`Command exited with code ${code}.`));
      }
    });
  });
};

Usage:

await execCommand('sudo apt-get update && sudo apt-get install -y docker.io docker-compose');

ref: https://stackoverflow.com/questions/10232192/exec-display-stdout-live

Proposed changes (including videos or screenshots)

Issue(s)

Further comments

@Anxhul10 Anxhul10 merged commit 9b165c0 into chore/loki Aug 17, 2025
2 checks passed
@Anxhul10 Anxhul10 deleted the chore/fuselageSnap-local-support branch August 17, 2025 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants